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/lib/python3.9/site-packages/pip/_internal/vcs/__pycache__/git.cpython-39.pyc
a

?�f�7�@sddlmZddlZddlZddlZddlmZddl	mZ
ddl	mZddl
mZmZddlmZmZddlmZddlmZdd	lmZdd
lmZmZmZmZer�ddlmZm Z ddlm!Z!dd
lm"Z"m#Z#e
j$Z$e
j%Z%e�&e'�Z(e�)d�Z*dd�Z+Gdd�de�Z,e�-e,�dS)�)�absolute_importN)�parse)�request)�
BadCommand�SubProcessError)�display_path�hide_url)�make_command)�
TempDirectory)�MYPY_CHECK_RUNNING)�RemoteNotFoundError�VersionControl�!find_path_to_setup_from_repo_root�vcs)�Optional�Tuple)�
HiddenText)�AuthInfo�
RevOptionsz^[a-fA-F0-9]{40}$cCstt�|��S�N)�bool�
HASH_REGEX�match)�sha�r�9/usr/lib/python3.9/site-packages/pip/_internal/vcs/git.py�looks_like_hash*srcs�eZdZdZdZdZdZdZdZe	dd��Z
d	d
�Zdd�Ze
d
d��Zdd�Ze
dd��Ze
dd��Ze
dd��Zdd�Zdd�Zdd�Ze
dd��Ze
d*d d!��Ze
d"d#��Ze
�fd$d%��Ze
d&d'��Ze
�fd(d)��Z�ZS)+�Git�gitz.git�clone)rzgit+httpz	git+httpszgit+sshzgit+gitzgit+file)ZGIT_DIRZ
GIT_WORK_TREE�HEADcCs|gSrr��revrrr�get_base_rev_args:szGit.get_base_rev_argscCsJ|�t|��\}}|jsdS|�||j�s.dSt|�||j�d�}|S)NFr)Zget_url_rev_optionsrr"�is_commit_id_equalr�get_revision_sha)�self�url�dest�_�rev_optionsZis_tag_or_branchrrr�is_immutable_rev_checkout>s�zGit.is_immutable_rev_checkoutcCsXd}|�dg�}|�|�r4|t|�d���d}nd}d�|�d�dd��}t|�S)Nzgit version �versionr��.�)�run_command�
startswith�len�split�join�
parse_version)r&ZVERSION_PFXr,rrr�get_git_versionOs
zGit.get_git_versioncCs>gd�}|j|d|d�}|��}|�d�r:|td�d�SdS)zl
        Return the current branch, or None if HEAD isn't at a branch
        (e.g. detached HEAD).
        )zsymbolic-ref�-qr ���Zextra_ok_returncodes�cwdzrefs/heads/N)r0�stripr1r2)�cls�location�args�output�refrrr�get_current_branch\s
�
zGit.get_current_branchcCsj|�d�s|d}tdd��:}|j|j|d�|jdddd|g|jd	�Wd
�n1s\0Yd
S)z@Export the Git repository at the url to the destination location�/�export)�kind)r'zcheckout-indexz-az-fz--prefix�r;N)�endswithr
�unpack�pathr0)r&r>r'Ztemp_dirrrrrDqs
�z
Git.exportc
	Cs�d}z|jd|g|d�}Wnty,Yn0i}|���d�D]T}|�d�}|sTq@z|jddd�\}}Wn ty�td	�|���Yn0|||<q@d
�|�}d�|�}	|�|�}|dur�|d
fS|�|	�}|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.
        r-zshow-refrF�
�
� �)�maxsplitzunexpected show-ref line: {!r}zrefs/remotes/origin/{}zrefs/tags/{}NTF)r0rr<r3�rstrip�
ValueError�format�get)
r=r(r"r@Zrefs�linerrAZ
branch_refZtag_refrrrr%~s,





zGit.get_revision_shacCs�|j}|dusJ�|�||�\}}|durF|�|�}|r<|nd|_|St|�sZt�d|�|�d�sh|S|jt	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.zrefs/�fetchr7rFZ
FETCH_HEADr!)Zarg_revr%Zmake_new�branch_namer�loggerZwarningr1r0r	�to_args�get_revision)r=r(r'r*r"rZ	is_branchrrr�resolve_revision�s*

�
�
zGit.resolve_revisioncCs|sdS|�|�|kS)z�
        Return whether the current commit hash equals the given name.

        Args:
          dest: the repository directory.
          name: a string name.
        F)rX)r=r(�namerrrr$�s	zGit.is_commit_id_equalcCs�|��}t�d||t|��|�tdd||��|jr�|�|||�}t|dd�}|dur�|�	||j�s�tdd|�
��}|j||d�n4|�|�|kr�d�|�}dd|d	|g}|j||d�|�
|�dS)
NzCloning %s%s to %srr7rU�checkoutrFz	origin/{}z-bz--track)Z
to_displayrV�inforr0r	r"rY�getattrr$rWrBrQ�update_submodules)r&r(r'r*Zrev_displayrU�cmd_argsZtrack_branchrrr�	fetch_new�s$
�

�z
Git.fetch_newcCsB|jtdd|�|d�tdd|���}|j||d�|�|�dS)N�configzremote.origin.urlrFr[r7)r0r	rWr^�r&r(r'r*r_rrr�switchs
�z
Git.switchcCsr|��td�kr$|jgd�|d�n|jddg|d�|�|||�}tddd|���}|j||d�|�|�dS)Nz1.9.0)rTr7z--tagsrFrTr7�resetz--hard)r6r5r0rYr	rWr^rbrrr�updatesz
Git.updatecCsr|jgd�d|d�}|��}z|d}Wnty>t�Yn0|D]}|�d�rD|}q\qD|�d�d}|��S)z�
        Return URL of the first remote encountered.

        Raises RemoteNotFoundError if the repository does not have a remote
        url configured.
        )raz--get-regexpzremote\..*\.urlr8r:rzremote.origin.url rLr9)r0�
splitlines�
IndexErrorrr1r3r<)r=r>�stdoutZremotesZfound_remoteZremoter'rrr�get_remote_url s
�

zGit.get_remote_urlNcCs&|durd}|jd|g|d�}|��S)Nr �	rev-parserF)r0r<)r=r>r"Zcurrent_revrrrrX;s�zGit.get_revisioncCsP|jddg|d���}tj�|�s0tj�||�}tj�tj�|d��}t||�S)z~
        Return the path to setup.py, relative to the repo root.
        Return None if setup.py is in the repo root.
        rjz	--git-dirrFz..)r0r<�osrI�isabsr4�abspathr)r=r>Zgit_dirZ	repo_rootrrr�get_subdirectoryDs�
zGit.get_subdirectorycs�t|�\}}}}}|�d�r�|dt|�d���}|t�|��dd��d�}t|||||f�}|�d�d}	|d|	�t||	d�||||f�}d|vr�d|vs�J�|�d	d
�}t	t
|��|�\}}
}|�dd�}nt	t
|��|�\}}
}||
|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.
        �fileNrC�\�+r9z://zfile:zgit+z
git+ssh://zssh://r-)�urlsplitrGr2�lstrip�urllib_requestZurl2pathname�replace�
urlunsplit�find�superr�get_url_rev_and_auth)r=r'�scheme�netlocrI�query�fragment�initial_slashes�newpathZ
after_plusr"Z	user_pass��	__class__rrrySs.

�����zGit.get_url_rev_and_authcCs0tj�tj�|d��sdS|jgd�|d�dS)Nz.gitmodules)Z	submodulerez--initz--recursiver7rF)rkrI�existsr4r0)r=r>rrrr^vs�zGit.update_submodulescsvtt|��|�}|r|Sz|jddg|dd�}Wn2tyPt�d|�YdStybYdS0tj	�
|�d��S)Nrjz--show-toplevelF)r;Zlog_failed_cmdzKcould not determine if %s is under git control because git is not availablez
)rxr�get_repository_rootr0rrV�debugrrkrI�normpathrO)r=r>Zloc�rr�rrr�s"�
�zGit.get_repository_root)N)�__name__�
__module__�__qualname__rZ�dirnameZ	repo_nameZschemesZ
unset_environZdefault_arg_rev�staticmethodr#r+r6�classmethodrBrDr%rYr$r`rcrerirXrnryr^r��
__classcell__rrr�rr.sD




-
,


"
r).Z
__future__rZloggingZos.pathrk�reZpip._vendor.packaging.versionrr5Zpip._vendor.six.moves.urllibZurllib_parserrtZpip._internal.exceptionsrrZpip._internal.utils.miscrrZpip._internal.utils.subprocessr	Zpip._internal.utils.temp_dirr
Zpip._internal.utils.typingrZ pip._internal.vcs.versioncontrolrr
rr�typingrrrrrrrrvZ	getLoggerr�rV�compilerrr�registerrrrr�<module>s2

g