HEX
Server: LiteSpeed
System: Linux php-prod-1.spaceapp.ru 5.15.0-157-generic #167-Ubuntu SMP Wed Sep 17 21:35:53 UTC 2025 x86_64
User: sport3497 (1034)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //usr/local/lib/python3.10/dist-packages/pip/_internal/vcs/__pycache__/git.cpython-310.pyc
o

��h�J�@sddlmZddlZddlZddlZddlZddlZddl	Zddl
mZddlm
Z
ddlmZmZddlmZmZmZddlmZddlmZmZmZmZmZmZmZejj Z ejj!Z!e�"e#�Z$e�%d	�Z&e�%d
�Z'e�%dej(�Z)ddd�Z*Gdd�de�Z+e�,e+�dS)�)�annotationsN)�replace)�Any)�
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�str�return�boolcCstt�|��S�N)r�
HASH_REGEX�match)r�r�@/usr/local/lib/python3.10/dist-packages/pip/_internal/vcs/git.py�looks_like_hash:srcsReZdZdZdZdZdZdZdZe	dJdd��Z
edK�fdd��ZdLdd�Z
dMdd�ZedNdd��ZedOdd ��ZedPd!d"��ZedQd&d'��ZedRd)d*��ZdSd.d/�Z	0dTdSd1d2�Z	0dTdSd3d4�ZedUd5d6��Ze	dVd7d8��ZedWd9d:��ZedXdYd<d=��ZedNd>d?��ZedZ�fdAdB��ZedTd[dCdD��ZedN�fdEdF��Ze	d\dHdI��Z�Z S)]�Git�gitz.git�clone)zgit+httpz	git+httpszgit+sshzgit+gitzgit+file)�GIT_DIR�
GIT_WORK_TREE�HEAD�revrr�	list[str]cCs|gSrr�r"rrr�get_base_rev_argsNszGit.get_base_rev_args�argsr�kwargscsBtj�d�r|�di�}d|d<d|d<||d<t�j|i|��S)N�PIP_NO_INPUT�
extra_environ�0�GIT_TERMINAL_PROMPTzssh -oBatchMode=yes�GIT_SSH_COMMAND)�os�environ�get�super�run_command)�clsr&r'r)��	__class__rrr1RszGit.run_command�url�destrcCsJ|�t|��\}}|jsdS|�||j�sdSt|�||j�d�}|S)NFr)�get_url_rev_optionsr	r"�is_commit_id_equalr�get_revision_sha)�selfr5r6�_�rev_options�is_tag_or_branchrrr�is_immutable_rev_checkout[szGit.is_immutable_rev_checkout�tuple[int, ...]cCsN|jdgdddd�}t�|�}|st�d|�dSt|�d��t|�d	��fS)
N�versionzgit versionFT)�command_desc�show_stdout�stdout_onlyzCan't parse git version: %sr��)r1�GIT_VERSION_REGEXr�logger�warning�int�group)r:r@rrrr�get_git_versionis�
zGit.get_git_version�location�
str | NonecCsBgd�}|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!�rDFT��extra_ok_returncodesrBrC�cwdzrefs/heads/N)r1�strip�
startswith�len)r2rLr&�output�refrrr�get_current_branchvs
�
zGit.get_current_branch�tuple[str | None, bool]c	Cs�|jd|g|dddd�}i}|���d�D](}|�d�}|sqz|jdd	d
�\}}Wnty8td|����w|||<qd|��}d
|��}	|�|�}
|
durU|
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)rRrBrC�
on_returncode�
�
� rE)�maxsplitzunexpected show-ref line: zrefs/remotes/origin/z
refs/tags/N)r1rS�split�rstrip�
ValueErrorr/)r2r6r"rV�refs�line�ref_sha�ref_name�
branch_ref�tag_refrrrrr9�s2�
�




zGit.get_revision_shacCs.|�d�rdSt|�s
dS|�||�rdSdS)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)rTr�
has_commit)r2r6r"rrr�
_should_fetch�s
	zGit._should_fetchrr<rcCs�|j}|dus	J�|�||�\}}|dur&|�|�}t||r |ndd�}|St|�s0t�d|�|�||�s8|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.
        N)�branch_namez:Did not find branch or tag '%s', assuming revision or ref.�fetchrN�rR�
FETCH_HEADr$)�arg_revr9�make_newrrrG�inforjr1r
�to_args�get_revision)r2r6r5r<r"r�	is_branchrrr�resolve_revision�s*
��
zGit.resolve_revision�namecCs|sdS|�|�|kS)z�
        Return whether the current commit hash equals the given name.

        Args:
          dest: the repository directory.
          name: a string name.
        F)rs)r2r6rvrrrr8s	zGit.is_commit_id_equal�	verbosityrI�NonecCsX|��}t�d||t|��|dkrd}n	|dkrd}nd}|��dkr5|�tdd	g|�|�|�R��n|�tdg|�|�|�R��|jr�|�|||�}t	|d
d�}t�
d||�|durv|�||j�sutdd
|���}|j||d�n%|�
|�|kr�d|��}	dd|d|	g}|j||d�n
|�|�}
|�|
�}t�d||j�|j||d�dS)NzCloning %s%s to %sr)z--quietrDr)z	--verbosez
--progress)rE�rz--filter=blob:nonerkzRev options %s, branch_name %s�checkoutrNrmzorigin/z-bz--trackzResolved %s to commit %s�rw)�
to_displayrGrqrrKr1r
r"ru�getattr�debugr8rrrXrsrp�update_submodules)r:r6r5r<rw�rev_display�flagsrk�cmd_args�track_branchrrrr�	fetch_news`�����
��
��

z
Git.fetch_newrcCsd|jtdd|�|d�g}|dkr|�d�tdg|�|���R�}|j||d�|j||d�dS)N�configzremote.origin.urlrmrrNrzr{)r1r
�appendrrr�r:r6r5r<rw�extra_flagsr�rrr�switchPs
�
z
Git.switchcCs�g}|dkr|�d�|��dkr|jddg|�|d�n
|jdg|�|d�|�|||�}tddg|�|���R�}|j||d�|j||d	�dS)
NrrN)rD�	rlz--tagsrm�resetz--hardr{)r�rKr1rur
rrrr�rrr�updatefs"
���z
Git.updatecCsx|jgd�ddd|d�}|��}z|d}Wn	tyt�w|D]}|�d�r-|}nq"|�d�d	}|�|���S)
z�
        Return URL of the first remote encountered.

        Raises RemoteNotFoundError if the repository does not have a remote
        url configured.
        )r�z--get-regexpzremote\..*\.urlrOFTrPrzremote.origin.url r^rD)r1�
splitlines�
IndexErrorrrTr`�_git_remote_to_pip_urlrS)r2rL�stdout�remotes�found_remote�remoter5rrr�get_remote_url�s(
��
�zGit.get_remote_urlcCsJt�d|�r|Stj�|�rt�|���St�|�}|r!|�	d�St
|��)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/\3)�rerr-�path�exists�pathlib�PurePath�as_uri�	SCP_REGEX�expandr
)r5�	scp_matchrrrr��s

zGit._git_remote_to_pip_urlcCs8z|jdddd|g|dd�WdStyYdSw)zU
        Check if rev is a commit that is available in the local repository.
        �	rev-parserNz--verifyzsha^F)rR�log_failed_cmdT)r1r)r2rLr"rrrri�s���zGit.has_commitNcCs*|durd}|jd|gdd|d�}|��S)Nr!r�FT�rBrCrR)r1rS)r2rLr"�current_revrrrrs�s�zGit.get_revisioncCsT|jddgdd|d���}tj�|�stj�||�}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.
        r�z	--git-dirFTr�z..)r1rSr-r��isabs�join�abspathr)r2rL�git_dir�	repo_rootrrr�get_subdirectory�s��
zGit.get_subdirectory� tuple[str, str | None, AuthInfo]cs�t|�\}}}}}|�d�rC|dt|�d���}|tj�|��dd��d�}|�d�d}	|d|	�t	||	d�||||f�}d|vrcd|vsMJ�|�d	d
�}t
��|�\}}
}|�dd�}n	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.
        �fileN�/�\�+rDz://zfile:zgit+z
git+ssh://zssh://�)�urlsplit�endswithrU�lstrip�urllib�request�url2pathnamer�find�
urlunsplitr0�get_url_rev_and_auth)r2r5�scheme�netlocr��query�fragment�initial_slashes�newpath�
after_plusr"�	user_passr3rrr��s&

���
zGit.get_url_rev_and_authcCsFgd�}|dkr
|�d�tj�tj�|d��sdS|j||d�dS)N)�	submoduler�z--initz--recursiverrNz.gitmodulesrm)r�r-r�r�r�r1)r2rLrw�argvrrrrs

�zGit.update_submodulescsxt��|�}|r
|Sz|jddg|ddddd�}Wnty)t�d|�YdSty2YdSwtj�	|�
d��S)	Nr�z--show-toplevelFT�raise)rRrBrCr[r�zKcould not determine if %s is under git control because git is not availablez
)r0�get_repository_rootr1rrGr~rr-r��normpathra)r2rL�loc�rr3rrr�s,
���zGit.get_repository_root�repo_urlcCsdS)zEIn either https or ssh form, requirements must be prefixed with git+.Tr)r�rrr�should_add_vcs_url_prefix5szGit.should_add_vcs_url_prefix)r"rrr#)r&rr'rrr)r5rr6rrr)rr?)rLrrrM)r6rr"rrrY)r6rr"rrr)r6rr5rr<rrr)r6rrvrMrr)
r6rr5rr<rrwrIrrx)r)rLrrr)r5rrr)rLrr"rrrr)rLrr"rMrr)r5rrr�)rLrrwrIrrx)r�rrr)!�__name__�
__module__�__qualname__rv�dirname�	repo_name�schemes�
unset_environ�default_arg_rev�staticmethodr%�classmethodr1r>rKrXr9rjrur8r�r�r�r�r�rirsr�r�rr�r��
__classcell__rrr3rr>s\	


--
D��
r)rrrr)-�
__future__r�logging�os.pathr-r�r��urllib.parser��urllib.request�dataclassesr�typingr�pip._internal.exceptionsrr�pip._internal.utils.miscrrr	�pip._internal.utils.subprocessr
� pip._internal.vcs.versioncontrolrrr
rrrr�parser�r��	getLoggerr�rG�compilerFr�VERBOSEr�rr�registerrrrr�<module>s>$

�

�