HEX
Server: Apache
System: Linux insrv.serversdaddy.com 5.14.0-362.24.2.el9_3.x86_64 #1 SMP PREEMPT_DYNAMIC Sat Mar 30 14:11:54 EDT 2024 x86_64
User: jsaha (1066)
PHP: 8.3.6
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //proc/self/root/lib/python3.9/site-packages/pip/_internal/vcs/__pycache__/git.cpython-39.pyc
a

g��e�C�@s�ddlZddlZddlZddlZddlZddlZddlm	Z	m
Z
mZddlm
Z
mZddlmZmZmZddlmZddlmZmZmZmZmZmZmZejjZejjZe� e!�Z"e�#d�Z$e�#d�Z%e�#d	ej&�Z'd
d�Z(Gdd
�d
e�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[^:]*)
$cCstt�|��S�N)�bool�
HASH_REGEX�match)�sha�r�9/usr/lib/python3.9/site-packages/pip/_internal/vcs/git.py�looks_like_hash4srcseZdZdZdZdZdZdZdZe	dd��Z
d	d
�Zee
dfd�d
d�Zedd��Zedd��Zedd��Zedd��Zedd��Zdd�Zdd�Zdd�Zedd ��Ze	d!d"��Zed#d$��Zed2d&d'��Zed(d)��Ze�fd*d+��Zed,d-��Ze�fd.d/��Ze	d0d1��Z �Z!S)3�Git�gitz.git�clone)zgit+httpz	git+httpszgit+sshzgit+gitzgit+file)ZGIT_DIRZ
GIT_WORK_TREE�HEADcCs|gSrr��revrrr�get_base_rev_argsEszGit.get_base_rev_argscCsJ|�t|��\}}|jsdS|�||j�s.dSt|�||j�d�}|S)NFr)Zget_url_rev_optionsr	r�is_commit_id_equalr�get_revision_sha)�self�url�dest�_�rev_optionsZis_tag_or_branchrrr�is_immutable_rev_checkoutJs�zGit.is_immutable_rev_checkout.)�returncCs:|jdgddd�}t�|�}|s$dStdd�|��D��S)N�versionFT)�show_stdout�stdout_onlyrcss|]}t|�VqdSr)�int)�.0�crrr�	<genexpr>b�z&Git.get_git_version.<locals>.<genexpr>)�run_command�GIT_VERSION_REGEXr�tuple�groups)r#r*rrrr�get_git_version[s�
zGit.get_git_versioncCsBgd�}|j|ddd|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��FT�Zextra_ok_returncodesr+r,�cwdzrefs/heads/N)r2�strip�
startswith�len)�cls�location�args�output�refrrr�get_current_branchds�
zGit.get_current_branchc	Cs�|jd|g|dddd�}i}|���d�D]T}|�d�}|s>q*z|jdd	d
�\}}Wn tyttd|����Yn0|||<q*d|��}d
|��}	|�|�}
|
dur�|
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�
�
� �)�maxsplitzunexpected show-ref line: zrefs/remotes/origin/z
refs/tags/N)r2r<�split�rstrip�
ValueError�get)r?r%rrBZrefs�lineZref_shaZref_nameZ
branch_refZtag_refrrrrr"~s0�





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%rrrr�
_should_fetch�s

zGit._should_fetchcCs�|j}|dusJ�|�||�\}}|durF|�|�}|r<|nd|_|St|�sZt�d|�|�||�sj|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.�fetchr7�r;Z
FETCH_HEADr)Zarg_revr"�make_new�branch_namer�loggerZwarningrRr2r
�to_args�get_revision)r?r%r$r'rrZ	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)rY)r?r%�namerrrr!�s
zGit.is_commit_id_equalc	Cs�|��}t�d||t|��|�tdd||��|jr�|�|||�}t|dd�}|dur�|�	||j�s�tdd|�
��}|j||d�q�|�|�|kr�d|��}dd|d	|g}|j||d�n|�|�}|�
|�}t�d
||j�|�|�dS)NzCloning %s%s to %srr7rV�checkoutrTzorigin/z-bz--trackzResolved %s to commit %s)Z
to_displayrW�inforr2r
rrZ�getattrr!rXrDrYrU�update_submodules)	r#r%r$r'Zrev_displayrV�cmd_argsZtrack_branchrrrr�	fetch_news*
�

�

z
Git.fetch_newcCsB|jtdd|�|d�tdd|���}|j||d�|�|�dS)N�configzremote.origin.urlrTr\r7)r2r
rXr_�r#r%r$r'r`rrr�switch%s
�z
Git.switchcCsn|��dkr |jgd�|d�n|jddg|d�|�|||�}tddd|���}|j||d�|�|�dS)N)r9�	)rSr7z--tagsrTrSr7�resetz--hard)r6r2rZr
rXr_rcrrr�update0sz
Git.updatecCs||jgd�ddd|d�}|��}z|d}WntyBt�Yn0|D]}|�d�rH|}q`qH|�d�d	}|�|���S)
z�
        Return URL of the first remote encountered.

        Raises RemoteNotFoundError if the repository does not have a remote
        url configured.
        )rbz--get-regexpzremote\..*\.urlr8FTr:rzremote.origin.url rIr9)r2�
splitlines�
IndexErrorrr=rL�_git_remote_to_pip_urlr<)r?r@�stdoutZremotesZfound_remoteZremoter$rrr�get_remote_url?s$�

zGit.get_remote_urlcCsNt�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_matchrrrrj^s

zGit._git_remote_to_pip_urlcCs>z |jdddd|g|dd�Wnty4YdS0dSdS)	zU
        Check if rev is a commit that is available in the local repository.
        �	rev-parser7z--verifyzsha^F)r;�log_failed_cmdTN)r2r)r?r@rrrrrQ~s�
zGit.has_commitNcCs*|durd}|jd|gdd|d�}|��S)NrrvFT�r+r,r;)r2r<)r?r@rZcurrent_revrrrrY�s�zGit.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.
        rvz	--git-dirFTrxz..)r2r<rnro�isabs�join�abspathr)r?r@Zgit_dirZ	repo_rootrrr�get_subdirectory�s�
zGit.get_subdirectorycs�t|�\}}}}}|�d�r�|dt|�d���}|tj�|��dd��d�}|�d�d}	|d|	�t	||	d�||||f�}d|vr�d|vs�J�|�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�/�\�+r9z://zfile:zgit+z
git+ssh://zssh://�)�urlsplit�endswithr>�lstrip�urllibZrequestZurl2pathname�replace�find�
urlunsplit�super�get_url_rev_and_auth)r?r$�scheme�netlocro�query�fragment�initial_slashes�newpathZ
after_plusrZ	user_pass��	__class__rrr��s,
�����zGit.get_url_rev_and_authcCs0tj�tj�|d��sdS|jgd�|d�dS)Nz.gitmodules)Z	submodulergz--initz--recursiver7rT)rnrorprzr2)r?r@rrrr_�s�zGit.update_submodulescsxt��|�}|r|Sz|jddg|ddddd�}Wn2tyRt�d|�YdStydYdS0tj�	|�
d��S)	Nrvz--show-toplevelFT�raise)r;r+r,rFrwzKcould not determine if %s is under git control because git is not availablez
)r��get_repository_rootr2rrW�debugrrnro�normpathrM)r?r@�loc�rr�rrr��s(�
�zGit.get_repository_rootcCsdS)zNIn either https or ssh form, requirements must be prefixed with git+.
        Tr)Zrepo_urlrrr�should_add_vcs_url_prefix�szGit.should_add_vcs_url_prefix)N)"�__name__�
__module__�__qualname__r[�dirnameZ	repo_nameZschemesZ
unset_environZdefault_arg_rev�staticmethodr r(rr-r6�classmethodrDr"rRrZr!rardrgrlrjrQrYr|r�r_r�r��
__classcell__rrr�rr9sR
	

.

,
#



!
	r)+ZloggingZos.pathrnrqrm�urllib.parser�Zurllib.request�typingrrrZpip._internal.exceptionsrrZpip._internal.utils.miscrrr	Zpip._internal.utils.subprocessr
Z pip._internal.vcs.versioncontrolrrr
rrrr�parser�r�Z	getLoggerr�rW�compiler3r�VERBOSErtrr�registerrrrr�<module>s4$

�
	�D