HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.7/site-packages/pip/_internal/vcs/__pycache__/git.cpython-37.pyc
B

L��g�F�@sddlZddlZddlZddlZddlZddlZddlm	Z	m
Z
mZddlm
Z
mZddlmZmZmZddlmZddlmZmZmZmZmZmZmZejjZejjZe� e!�Z"e�#d�Z$e�#d�Z%e�#d	ej&�Z'e(e)d
�dd�Z*Gd
d�de�Z+e�,e+�dS)�N)�List�Optional�Tuple)�
BadCommand�InstallationError)�
HiddenText�display_path�hide_url)�make_command)�AuthInfo�RemoteNotFoundError�RemoteNotValidError�
RevOptions�VersionControl�(find_path_to_project_root_from_repo_root�vcsz(^git version (\d+)\.(\d+)(?:\.(\d+))?.*$z^[a-fA-F0-9]{40}$a/^
    # Optional user, e.g. 'git@'
    (\w+@)?
    # Server, e.g. 'github.com'.
    ([^/:]+):
    # The server-side path. e.g. 'user/project.git'. Must start with an
    # alphanumeric character so as not to be confusable with a Windows paths
    # like 'C:/foo/bar' or 'C:\foo\bar'.
    (\w[^:]*)
    $)�sha�returncCstt�|��S)N)�bool�
HASH_REGEX�match)r�r�9/tmp/pip-unpacked-wheel-hv55ucu3/pip/_internal/vcs/git.py�looks_like_hash7srcseZdZdZdZdZdZdZdZe	e
ee
d�dd	��Ze
e
e
d
�dd�Zeed
fd�dd�Zee
ee
d�dd��Zee
e
eee
e
fd�dd��Zee
e
e
d�dd��Zee
eeed�dd��Zee
ee
e
d�dd��Ze
eeedd �d!d"�Ze
eedd�d#d$�Ze
eedd�d%d&�Zee
e
d�d'd(��Ze	e
e
d)�d*d+��Zee
e
e
d,�d-d.��Z ed<e
ee
e
d,�d/d0��Z!ee
ee
d�d1d2��Z"ee
ee
ee
e#fd)��fd3d4��Z$ee
dd�d5d6��Z%ee
ee
d��fd7d8��Z&e	e
e
d9�d:d;��Z'�Z(S)=�Git�gitz.git�clone)zgit+httpz	git+httpszgit+sshzgit+gitzgit+file)�GIT_DIR�
GIT_WORK_TREE�HEAD)�revrcCs|gS)Nr)r rrr�get_base_rev_argsKszGit.get_base_rev_args)�url�destrcCsJ|�t|��\}}|jsdS|�||j�s.dSt|�||j�d�}|S)NFr)�get_url_rev_optionsr	r �is_commit_id_equalr�get_revision_sha)�selfr"r#�_�rev_options�is_tag_or_branchrrr�is_immutable_rev_checkoutOszGit.is_immutable_rev_checkout.)rcCsN|jdgdddd�}t�|�}|s2t�d|�dSt|�d��t|�d	��fS)
N�versionzgit versionFT)�command_desc�show_stdout�stdout_onlyzCan't parse git version: %sr��)�run_command�GIT_VERSION_REGEXr�logger�warning�int�group)r'r,rrrr�get_git_version]s
zGit.get_git_version)�locationrcCsDdddg}|j|ddd|d�}|��}|�d�r@|td�d	�Sd	S)
zl
        Return the current branch, or None if HEAD isn't at a branch
        (e.g. detached HEAD).
        zsymbolic-refz-qr)r0FT)�extra_ok_returncodesr.r/�cwdzrefs/heads/N)r2�strip�
startswith�len)�clsr9�args�output�refrrr�get_current_branchjs


zGit.get_current_branch)r#r rc	Cs�|jd|g|dddd�}i}xh|���d�D]V}|�d�}|s@q,y|jdd	d
�\}}Wn"tk
rxtd|����YnX|||<q,Wd|��}d
|��}	|�|�}
|
dk	r�|
dfS|�|	�}
|
dfS)z�
        Return (sha_or_none, is_branch), where sha_or_none is a commit hash
        if the revision names a remote branch or tag, otherwise None.

        Args:
          dest: the repository directory.
          rev: the revision name.
        zshow-refFT�ignore)r;r.r/�
on_returncode�
�
� r1)�maxsplitzunexpected show-ref line: zrefs/remotes/origin/z
refs/tags/N)r2r<�split�rstrip�
ValueError�get)r?r#r rA�refs�lineZref_shaZref_name�
branch_ref�tag_refrrrrr&�s.




zGit.get_revision_shacCs.|�d�rdSt|�sdS|�||�r*dSdS)a$
        Return true if rev is a ref or is a commit that we don't have locally.

        Branches and tags are not considered in this method because they are
        assumed to be always available locally (which is a normal outcome of
        ``git clone`` and ``git fetch --tags``).
        zrefs/TF)r=r�
has_commit)r?r#r rrr�
_should_fetch�s	
zGit._should_fetch)r#r"r)rcCs�|j}|dk	st�|�||�\}}|dk	rF|�|�}|r<|nd|_|St|�sZt�d|�|�||�sj|S|j	t
dd||���|d�|j|dd�}|�|�}|S)z�
        Resolve a revision to a new RevOptions object with the SHA1 of the
        branch, tag, or ref if found.

        Args:
          rev_options: a RevOptions object.
        Nz:Did not find branch or tag '%s', assuming revision or ref.�fetchz-q)r;�
FETCH_HEAD)r )
�arg_rev�AssertionErrorr&�make_new�branch_namerr4r5rSr2r
�to_args�get_revision)r?r#r"r)r r�	is_branchrrr�resolve_revision�s&

zGit.resolve_revision)r#�namercCs|sdS|�|�|kS)z�
        Return whether the current commit hash equals the given name.

        Args:
          dest: the repository directory.
          name: a string name.
        F)r[)r?r#r^rrrr%�s	zGit.is_commit_id_equalN)r#r"r)�	verbosityrcCsJ|��}t�d||t|��|dkr*d}n|dkr8d}nd}|��dkrb|�td|||f���n|�td|||f���|j�r|�|||�}t	|d
d�}t�
d||�|dkr�|�||j�s�tdd
|���}|j||d�n6|�
|�|k�r,d|��}	dd|d|	g}|j||d�n|�|�}
|�|
�}t�d||j�|�|�dS)NzCloning %s%s to %sr)z--quietr0r)z	--verbosez
--progress)r1�r�--filter=blob:nonerYzRev options %s, branch_name %s�checkoutz-q)r;zorigin/z-bz--trackzResolved %s to commit %s)rra)r)�
to_displayr4�inforr8r2r
r r]�getattr�debugr%rZrCr[rX�update_submodules)r'r#r"r)r_�rev_display�flagsrY�cmd_args�track_branchrrrr�	fetch_newsN



z
Git.fetch_newcCsB|jtdd|�|d�tdd|���}|j||d�|�|�dS)N�configzremote.origin.url)r;rbz-q)r2r
rZrg)r'r#r"r)rjrrr�switchDs
z
Git.switchcCsp|��dkr"|jdddg|d�n|jddg|d�|�|||�}tddd|���}|j||d�|�|�dS)N)r0�	rTz-qz--tags)r;�resetz--hard)r8r2r]r
rZrg)r'r#r"r)rjrrr�updateNsz
Git.updatecCs�|jdddgddd|d�}|��}y|d}Wntk
rFt�YnXx|D]}|�d	�rN|}PqNW|�d
�d}|�|���S)z�
        Return URL of the first remote encountered.

        Raises RemoteNotFoundError if the repository does not have a remote
        url configured.
        rmz--get-regexpzremote\..*\.url)r0FT)r:r.r/r;rzremote.origin.url rHr0)r2�
splitlines�
IndexErrorrr=rJ�_git_remote_to_pip_urlr<)r?r9�stdout�remotes�found_remote�remoter"rrr�get_remote_url\s"



zGit.get_remote_url)r"rcCsNt�d|�r|Stj�|�r*t�|���St�|�}|rB|�	d�St
|��dS)a8
        Convert a remote url from what git uses to what pip accepts.

        There are 3 legal forms **url** may take:

            1. A fully qualified url: ssh://git@example.com/foo/bar.git
            2. A local project.git folder: /path/to/bare/repository.git
            3. SCP shorthand for form 1: git@example.com:foo/bar.git

        Form 1 is output as-is. Form 2 must be converted to URI and form 3 must
        be converted to form 1.

        See the corresponding test test_git_remote_url_to_pip() for examples of
        sample inputs/outputs.
        z\w+://z
ssh://\1\2/\3N)�rer�os�path�exists�pathlib�PurePath�as_uri�	SCP_REGEX�expandr
)r"Z	scp_matchrrrrtzs

zGit._git_remote_to_pip_url)r9r rcCs>y |jdddd|g|dd�Wntk
r4dSXdSdS)	zU
        Check if rev is a commit that is available in the local repository.
        z	rev-parsez-qz--verifyzsha^F)r;�log_failed_cmdTN)r2r)r?r9r rrrrR�szGit.has_commitcCs*|dkrd}|jd|gdd|d�}|��S)Nrz	rev-parseFT)r.r/r;)r2r<)r?r9r �current_revrrrr[�szGit.get_revisioncCsT|jddgdd|d���}tj�|�s4tj�||�}tj�tj�|d��}t||�S)z�
        Return the path to Python project root, relative to the repo root.
        Return None if the project root is in the repo root.
        z	rev-parsez	--git-dirFT)r.r/r;z..)r2r<r{r|�isabs�join�abspathr)r?r9�git_dir�	repo_rootrrr�get_subdirectory�szGit.get_subdirectorycs�t|�\}}}}}|�d�r�|dt|�d���}|tj�|��dd��d�}|�d�d}	|d|	�t	||	d�||||f�}d|kr�d|ks�t
�|�d	d
�}t��|�\}}
}|�dd�}nt��|�\}}
}||
|fS)
a9
        Prefixes stub URLs like 'user@hostname:user/repo.git' with 'ssh://'.
        That's required because although they use SSH they sometimes don't
        work with a ssh:// scheme (e.g. GitHub). But we need a scheme for
        parsing. Hence we remove it again afterwards and return it as a stub.
        �fileN�/�\�+r0z://zfile:zgit+z
git+ssh://zssh://�)
�urlsplit�endswithr>�lstrip�urllib�request�url2pathname�replace�find�
urlunsplitrW�super�get_url_rev_and_auth)r?r"�scheme�netlocr|�query�fragment�initial_slashes�newpath�
after_plusr �	user_pass)�	__class__rrr��s 

zGit.get_url_rev_and_authcCs6tj�tj�|d��sdS|jdddddg|d�dS)Nz.gitmodules�	submodulerqz--initz--recursivez-q)r;)r{r|r}r�r2)r?r9rrrrg�s
zGit.update_submodulescsxt��|�}|r|Sy|jddg|ddddd�}Wn2tk
rRt�d|�dStk
rddSXtj�	|�
d��S)	Nz	rev-parsez--show-toplevelFT�raise)r;r.r/rEr�zKcould not determine if %s is under git control because git is not availablez
)r��get_repository_rootr2rr4rfrr{r|�normpathrK)r?r9�loc�r)r�rrr��s&zGit.get_repository_root)�repo_urlrcCsdS)zEIn either https or ssh form, requirements must be prefixed with git+.Tr)r�rrr�should_add_vcs_url_prefixszGit.should_add_vcs_url_prefix)N))�__name__�
__module__�__qualname__r^�dirname�	repo_name�schemes�
unset_environ�default_arg_rev�staticmethod�strrr!rr+rr6r8�classmethodrrCr&rSrrr]r%rlrnrqryrtrRr[r�rr�rgr�r��
__classcell__rr)r�rr;sV
 -+=
$r)-�logging�os.pathr{r~rz�urllib.parser��urllib.request�typingrrr�pip._internal.exceptionsrr�pip._internal.utils.miscrrr	�pip._internal.utils.subprocessr
� pip._internal.vcs.versioncontrolrrr
rrrr�parser�r��	getLoggerr�r4�compiler3r�VERBOSEr�r�rrr�registerrrrr�<module>s2$



V