Sh3ll
OdayForums


Server : LiteSpeed
System : Linux premium84.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64
User : claqxcrl ( 523)
PHP Version : 8.1.32
Disable Function : NONE
Directory :  /opt/alt/python310/lib/python3.10/site-packages/pip/_internal/vcs/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //opt/alt/python310/lib/python3.10/site-packages/pip/_internal/vcs/__pycache__/git.cpython-310.pyc
o

ƚRe�E�@sddlZddlZddlZddlZddlZddlZddlm	Z	m
Z
mZddlm
Z
mZddlmZmZmZddlmZddlmZmZmZmZmZmZmZejjZejjZe� e!�Z"e�#d�Z$e�#d�Z%e�#d	ej&�Z'd
e(de)fdd
�Z*Gdd�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��/builddir/build/BUILDROOT/alt-python310-pip-21.3.1-3.el8.x86_64/opt/alt/python310/lib/python3.10/site-packages/pip/_internal/vcs/git.py�looks_like_hash7src	sDeZdZdZdZdZdZdZdZe	de
dee
fd	d
��Zde
de
de
fd
d�Zdeedffdd�Zede
dee
fdd��Zede
de
deee
e
ffdd��Zede
de
de
fdd��Zede
dededefdd��Zede
dee
de
fdd��Zde
dededdfd d!�Zde
dededdfd"d#�Zde
dededdfd$d%�Zede
de
fd&d'��Ze	de
de
fd(d)��Zede
de
de
fd*d+��Z ed9de
dee
de
fd,d-��Z!ede
dee
fd.d/��Z"ede
dee
ee
e#ff�fd0d1��Z$ede
ddfd2d3��Z%ede
dee
f�fd4d5��Z&e	d6e
de
fd7d8��Z'�Z(S):�Git�gitz.git�clone)zgit+httpz	git+httpszgit+sshzgit+gitzgit+file)�GIT_DIR�
GIT_WORK_TREE�HEAD�revrcCs|gSrr�r!rrr�get_base_rev_argsKszGit.get_base_rev_args�url�destcCsJ|�t|��\}}|jsdS|�||j�sdSt|�||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.cCsF|jdgddd�}t�|�}|st�d|�dStdd�|��D��S)	N�versionFT)�show_stdout�stdout_onlyzCan't parse git version: %srcss�|]}t|�VqdSr)�int)�.0�crrr�	<genexpr>cs�z&Git.get_git_version.<locals>.<genexpr>)�run_command�GIT_VERSION_REGEXr�logger�warning�tuple�groups)r)r.rrrr�get_git_version]s
zGit.get_git_version�locationcCsBgd�}|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��extra_ok_returncodesr/r0�cwdzrefs/heads/N)r5�strip�
startswith�len)�clsr<�args�output�refrrr�get_current_branches
�
zGit.get_current_branchc	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)rBr/r0�
on_returncode�
�
� �)�maxsplitzunexpected show-ref line: zrefs/remotes/origin/z
refs/tags/N)r5rC�split�rstrip�
ValueError�get)rFr%r!rH�refs�line�ref_sha�ref_name�
branch_ref�tag_refrrrrr(~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)rDr�
has_commit)rFr%r!rrr�
_should_fetch�s
	zGit._should_fetchr+cCs�|j}|dus	J�|�||�\}}|dur&|�|�}|r!||_|Sd|_|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.
        Nz:Did not find branch or tag '%s', assuming revision or ref.�fetchr=�rB�
FETCH_HEADr")�arg_revr(�make_new�branch_namerr7r8r]r5r
�to_args�get_revision)rFr%r$r+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)re)rFr%rhrrrr'�s	zGit.is_commit_id_equalNc	Cs |��}t�d||t|��|��dkr |�tddd||��n
|�tdd||��|jrw|�|||�}t	|dd�}t�
d||�|dur\|�||j�s[tdd|���}|j||d	�n%|�
|�|krvd
|��}dd|d|g}|j||d	�n
|�|�}|�|�}t�d
||j�|�|�dS)NzCloning %s%s to %s)rP�rz--filter=blob:noner=rczRev options %s, branch_name %s�checkoutr_zorigin/z-bz--trackzResolved %s to commit %s)�
to_displayr7�inforr;r5r
r!rg�getattr�debugr'rdrJrerb�update_submodules)	r)r%r$r+�rev_displayrc�cmd_args�track_branchrrrr�	fetch_newsP��
��
��

z
Git.fetch_newcCsB|jtdd|�|d�tdd|���}|j||d�|�|�dS)N�configzremote.origin.urlr_rjr=)r5r
rdro�r)r%r$r+rqrrr�switch7s
�z
Git.switchcCsn|��dkr|jgd�|d�n	|jddg|d�|�|||�}tddd|���}|j||d�|�|�dS)N)r?�	)r^r=z--tagsr_r^r=�resetz--hard)r;r5rgr
rdrorurrr�updateAs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.
        )rtz--get-regexpzremote\..*\.urlr>FTr@rzremote.origin.url rOr?)r5�
splitlines�
IndexErrorrrDrR�_git_remote_to_pip_urlrC)rFr<�stdout�remotes�found_remote�remoter$rrr�get_remote_urlOs(
��
�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)�rer�os�path�exists�pathlib�PurePath�as_uri�	SCP_REGEX�expandr
)r$�	scp_matchrrrr|ms

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-parser=z--verifyzsha^F)rB�log_failed_cmdT)r5r)rFr<r!rrrr\�s���zGit.has_commitcCs*|durd}|jd|gdd|d�}|��S)Nr r�FT�r/r0rB)r5rC)rFr<r!�current_revrrrre�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..)r5rCr�r��isabs�join�abspathr)rFr<�git_dir�	repo_rootrrr�get_subdirectory�s��
zGit.get_subdirectoryc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�/�\�+r?z://zfile:zgit+z
git+ssh://zssh://�)�urlsplit�endswithrE�lstrip�urllib�request�url2pathname�replace�find�
urlunsplit�super�get_url_rev_and_auth)rFr$�scheme�netlocr��query�fragment�initial_slashes�newpath�
after_plusr!�	user_pass��	__class__rrr��s&

���
zGit.get_url_rev_and_authcCs0tj�tj�|d��s
dS|jgd�|d�dS)Nz.gitmodules)�	submoduleryz--initz--recursiver=r_)r�r�r�r�r5)rFr<rrrro�s
�zGit.update_submodulescsxt��|�}|r
|Sz|jddg|ddddd�}Wnty)t�d|�YdSty2YdSwtj�	|�
d��S)	Nr�z--show-toplevelFT�raise)rBr/r0rLr�zKcould not determine if %s is under git control because git is not availablez
)r��get_repository_rootr5rr7rnrr�r��normpathrS)rFr<�loc�rr�rrr��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_prefix�szGit.should_add_vcs_url_prefixr))�__name__�
__module__�__qualname__rh�dirname�	repo_name�schemes�
unset_environ�default_arg_rev�staticmethod�strrr#rr-rr1r;�classmethodrrJr(r]rrrgr'rsrvryr�r|r\rer�rr�ror�r��
__classcell__rrr�rr;sd	$-����-7
&r)-�logging�os.pathr�r�r��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�r7�compiler6r�VERBOSEr�r�rrr�registerrrrr�<module>s8$

�

�I

ZeroDay Forums Mini