Viewing File: /opt/imunify360/venv/lib/python3.11/site-packages/pip/_internal/vcs/__pycache__/git.cpython-311.pyc

�

L�i�J���ddlmZddlZddlZddlZddlZddlZddl	Zddl
mZddlm
Z
ddlmZmZddlmZmZmZddlmZddlmZmZmZmZmZmZmZejj Z ejj!Z!ej"e#��Z$ej%d	��Z&ej%d
��Z'ej%dej(��Z)dd�Z*Gd�de��Z+ej,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�boolc�P�tt�|����S�N)r�
HASH_REGEX�match)rs �u/builddir/build/BUILD/imunify360-venv-2.6.1/opt/imunify360/venv/lib/python3.11/site-packages/pip/_internal/vcs/git.py�looks_like_hashr:s���
� � ��%�%�&�&�&�c����eZdZdZdZdZdZdZdZe	d5d���Z
ed6�fd���Zd7d�Z
d8d�Zed9d���Zed:d���Zed;d���Zed<d���Zed=d!���Zd>d%�Z	d?d>d'�Z	d?d>d(�Zed@d)���Ze	dAd*���ZedBd+���ZedCdDd-���Zed9d.���ZedE�fd0���Zed?dFd1���Zed9�fd2���Ze	dGd4���Z�xZ S)H�Git�gitz.git�clone)zgit+httpz	git+httpszgit+sshzgit+gitzgit+file)�GIT_DIR�
GIT_WORK_TREE�HEAD�revrr�	list[str]c��|gSr��r%s r�get_base_rev_argszGit.get_base_rev_argsNs	���u�r�argsr�kwargsc���tj�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__s    �rr7zGit.run_commandRsh���
�:�>�>�.�)�)�	4�"�J�J���;�;�M�36�M�/�0�/D�M�+�,�&3�F�?�#�"�u�w�w�"�D�3�F�3�3�3r�url�destrc��|�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_branchs      r�is_immutable_rev_checkoutzGit.is_immutable_rev_checkout[s���1�1�(�3�-�-�@�@���;���	��5��&�&�t�[�_�=�=�	��5� �� 5� 5�d�K�O� L� L�Q� O�P�P��#�#�#r�tuple[int, ...]c�0�|�dgddd���}t�|��}|st�d|��dSt|�d����t|�d	����fS)
N�versionzgit versionFT)�command_desc�show_stdout�stdout_onlyzCan't parse git version: %sr(��)r7�GIT_VERSION_REGEXr�logger�warning�int�group)r@rGrs   r�get_git_versionzGit.get_git_versionis����"�"�
�K�&���	#�
�
��"�'�'��0�0���	��N�N�8�'�B�B�B��2��E�K�K��N�N�#�#�S����Q���%8�%8�9�9r�location�
str | Nonec���gd�}|�|ddd|���}|���}|�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$�rKFT��extra_ok_returncodesrIrJ�cwdzrefs/heads/N)r7�strip�
startswith�len)r8rSr+�output�refs     r�get_current_branchzGit.get_current_branchvsw��.�-�-������!%����!�
�
���l�l�n�n���>�>�-�(�(�	-��s�=�)�)�+�+�,�,��tr�tuple[str | None, bool]c��|�d|g|ddd���}i}|����d��D][}|�d��}|s�	|�dd	�
��\}}n #t$rt	d|�����wxYw|||<�\d|��}d
|��}	|�|��}
|
�|
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)rZrIrJ�
on_returncode�
�
� rL)�maxsplitzunexpected show-ref line: zrefs/remotes/origin/z
refs/tags/)r7r[�split�rstrip�
ValueErrorr5)r8r;r%r^�refs�line�ref_sha�ref_name�
branch_ref�tag_refrs           rr?zGit.get_revision_sha�s6�����
������"�!�
�
�����L�L�N�N�(�(��.�.�	%�	%�D��;�;�t�$�$�D��
��
H�$(�J�J�s�Q�J�$?�$?�!������
H�
H�
H�!�!F�d�!F�!F�G�G�G�
H����
%�D��N�N�1�C�1�1�
�$�s�$�$���h�h�z�"�"���?���;���h�h�w�����U�|�s�!A<�<Bc��|�d��rdSt|��sdS|�||��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)r\r�
has_commit)r8r;r%s   r�
_should_fetchzGit._should_fetch�sR���>�>�'�"�"�	��4��s�#�#�	��5��>�>�$��$�$�	��5��trrrBrc	��|j}|�J�|�||��\}}|�,|�|��}t||r|nd���}|St	|��st
�d|��|�||��s|S|�tdd||�
����|���|�|d���}|�|��}|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.�fetchrV�rZ�
FETCH_HEADr))�arg_revr?�make_newrrrN�infortr7r�to_args�get_revision)r8r;r:rBr%r�	is_branchs       r�resolve_revisionzGit.resolve_revision�s(���!�������-�-�d�C�8�8���Y��?�%�.�.�s�3�3�K�!�+�9�<V�C�C�RV�X�X�X�K����s�#�#�	��K�K�L��
�
�
�
� � ��s�+�+�	���	�����$��[�-@�-@�-B�-B�C�C��	�	
�	
�	
�
���t���6�6��!�*�*�3�/�/���r�namec�<�|sdS|�|��|kS)z�
        Return whether the current commit hash equals the given name.

        Args:
          dest: the repository directory.
          name: a string name.
        F)r~)r8r;r�s   rr>zGit.is_commit_id_equals*���	��5�����%�%��-�-r�	verbosityrP�Nonec���|���}t�d||t|����|dkrd}n|dkrd}nd}|���dkr&|�t
dd	g|�|�|�R���n$|�t
dg|�|�|�R���|jr�|�|||��}t|d
d��}t�
d||��|�V|�||j��s:t
dd
|�����}|�||���ng|�
|��|kr#d|��}	dd|d|	g}|�||���n*|�|��}
|�|
��}t�d||j��|�||���dS)NzCloning %s%s to %sr)z--quietrKr()z	--verbosez
--progress)rL�r!z--filter=blob:nonervzRev options %s, branch_name %s�checkoutrVrxzorigin/z-bz--trackzResolved %s to commit %s�r�)�
to_displayrNr|r	rRr7rr%r��getattr�debugr>r}r`r~r{�update_submodules)r@r;r:rBr��rev_display�flagsrv�cmd_args�track_branchrs           r�	fetch_newz
Git.fetch_news\��"�,�,�.�.�����(�#�{�L��<N�<N�O�O�O���>�>�%1�E�E�
�!�^�^��E�E�/�E����!�!�W�,�,�
�����(�����	�
����
�
�
�
�
���\�'�E�E�E�3�E��E�E�E�F�F�F��?�	4��/�/��c�;�G�G�K�!�+�}�d�C�C�K��L�L�9�;��T�T�T��"��.�.�t�[�_�E�E�9�+�"��#�+�+�-�-� � �H�
�$�$�X�4�$�8�8�8���(�(��.�.�+�=�=� 7��6�6������ ���� � ��t� �4�4�4���#�#�D�)�)�C�%�.�.�s�3�3�K����.��[�_�E�E�E�	
���t�y��9�9�9�9�9rrc�*�|�tdd|��|���g}|dkr|�d��tdg|�|����R�}|�||���|�||���dS)N�configzremote.origin.urlrxrrVr�r�)r7r�appendr}r��r@r;r:rBr��extra_flagsr�s       r�switchz
Git.switchPs���	
�����#6��<�<��	�	
�	
�	
�
����>�>����t�$�$�$��
�P�[�P�+�:M�:M�:O�:O�P�P�P������t��,�,�,����t�y��9�9�9�9�9rc��g}|dkr|�d��|���dkr|�ddg|�|���n|�dg|�|���|�|||��}t	ddg|�|����R�}|�||���|�||�	��dS)
NrrV)rK�	rwz--tagsrx�resetz--hardr�)r�rRr7r�rr}r�r�s       r�updatez
Git.updatefs������>�>����t�$�$�$����!�!�V�+�+����g�x�>�+�>�D��I�I�I�I����g�4��4�$��?�?�?��+�+�D�#�{�C�C�����
��
�
���!�!�	
�
�
��	
����t��,�,�,����t�y��9�9�9�9�9rc�`�|�gd�ddd|���}|���}	|d}n#t$rt�wxYw|D]}|�d��r|}n�|�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\..*\.urlrWFTrXrzremote.origin.url rgrK)r7�
splitlines�
IndexErrorr
r\ri�_git_remote_to_pip_urlr[)r8rS�stdout�remotes�found_remote�remoter:s       r�get_remote_urlzGit.get_remote_url�s������:�:�:�!%����!�
�
���#�#�%�%��	&�"�1�:�L�L���	&�	&�	&�%�%�	&�����	�	�F�� � �!5�6�6�
�%����
�� � ��%�%�a�(���)�)�#�)�)�+�+�6�6�6s	�;�A
c�:�tjd|��r|Stj�|��r&tj|�����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)�rerr3�path�exists�pathlib�PurePath�as_uri�	SCP_REGEX�expandr)r:�	scp_matchs  rr�zGit._git_remote_to_pip_url�s���"�8�I�s�#�#�	��J�
�7�>�>�#���	2��#�C�(�(�/�/�1�1�1��O�O�C�(�(�	��	6��#�#�$4�5�5�5�!�#�&�&�&rc�h�	|�dddd|zg|d���dS#t$rYdSwxYw)zU
        Check if rev is a commit that is available in the local repository.
        �	rev-parserVz--verifyzsha^F)rZ�log_failed_cmdT)r7r)r8rSr%s   rrszGit.has_commit�sc��
		��O�O��d�J����=��$�
�
�
�
��4��!�	�	�	��5�5�	���s�#�
1�1Nc�h�|�d}|�d|gdd|���}|���S)Nr$r�FT�rIrJrZ)r7r[)r8rSr%�current_revs    rr~zGit.get_revision�sI���;��C��o�o�
�#�����	&�
�
��� � �"�"�"rc�t�|�ddgdd|������}tj�|��s tj�||��}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..)r7r[r3r��isabs�join�abspathr)r8rS�git_dir�	repo_roots    r�get_subdirectoryzGit.get_subdirectory�s����/�/�
�+�&����	"�
�
�
�%�'�'�	��w�}�}�W�%�%�	6��g�l�l�8�W�5�5�G��G�O�O�B�G�L�L��$�$?�$?�@�@�	�7��)�L�L�Lr� tuple[str, str | None, AuthInfo]c����t|��\}}}}}|�d��r�|dt|�d�����}|tj�|���dd���d��z}|�d��dz}	|d|	�t||	d�||||f��z}d|vrXd|vsJ�|�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�/�\�+rKz://zfile:zgit+z
git+ssh://zssh://�)�urlsplit�endswithr]�lstrip�urllib�request�url2pathnamer�find�
urlunsplitr6�get_url_rev_and_auth)
r8r:�scheme�netlocr��query�fragment�initial_slashes�newpath�
after_plusr%�	user_passr9s
            �rr�zGit.get_url_rev_and_auth�so���19��
�
�-����e�X��?�?�6�"�"�	�"�#;�c�$�+�+�c�*:�*:�&;�&;�%;�#;�<�O�%���(C�(C�D�(I�(I�(Q�(Q��c�)�)��f�S�k�k��G� ���S�)�)�A�-�J���*��%�
��
���$�f�g�u�h�G�)�)��C������#�%�%�%�%��+�+�f�l�3�3�C�"'�'�'�">�">�s�"C�"C��C��i��+�+�h��+�+�C�C�"'�'�'�">�">�s�"C�"C��C��i��C��"�"rc���gd�}|dkr|�d��tj�tj�|d����sdS|�||���dS)N)�	submoduler�z--initz--recursiverrVz.gitmodulesrx)r�r3r�r�r�r7)r8rSr��argvs    rr�zGit.update_submoduless~��?�?�?����>�>��K�K������w�~�~�b�g�l�l�8�]�C�C�D�D�	��F������	�	
�	
�	
�	
�	
rc�`��t���|��}|r|S	|�ddg|dddd���}n8#t$rt�d|��YdSt$rYdSwxYwtj�	|�
d����S)	Nr�z--show-toplevelFT�raise)rZrIrJrdr�zKcould not determine if %s is under git control because git is not availablez
)r6�get_repository_rootr7rrNr�rr3r��normpathrj)r8rS�loc�rr9s    �rr�zGit.get_repository_roots�����g�g�)�)�(�3�3���	��J�	�����/�0��!� �%�$�
 ���A�A���	�	�	��L�L�/��
�
�
�
�4�4� �	�	�	��4�4�	�����w������� 0� 0�1�1�1s�A�%A;�.	A;�:A;�repo_urlc��dS)zEIn either https or ssh form, requirements must be prefixed with git+.Tr()r�s r�should_add_vcs_url_prefixzGit.should_add_vcs_url_prefix5s	���tr)r%rrr&)r+rr,rrr)r:rr;rrr)rrE)rSrrrT)r;rr%rrra)r;rr%rrr)r;rr:rrBrrr)r;rr�rTrr)
r;rr:rrBrr�rPrr�)r)rSrrr)r:rrr)rSrr%rrrr)rSrr%rTrr)r:rrr�)rSrr�rPrr�)r�rrr)!�__name__�
__module__�__qualname__r��dirname�	repo_name�schemes�
unset_environ�default_arg_rev�staticmethodr*�classmethodr7rDrRr`r?rtr�r>r�r�r�r�r�rsr~r�r�r�r�r��
__classcell__)r9s@rrr>s���������D��G��I��G�1�M��O������\���4�4�4�4�4��[�4�$�$�$�$�:�:�:�:������[��0�+�+�+��[�+�Z�����[��,�+�+�+��[�+�Z�.�.�.��[�.�=:�=:�=:�=:�H�:�:�:�:�:�6�:�:�:�:�:�<�7�7�7��[�7�:�'�'�'��\�'�<�
�
�
��[�
��	#�	#�	#�	#��[�	#��M�M�M��[�M�"�#�#�#�#�#��[�#�<�
�
�
�
��[�
��2�2�2�2�2��[�2�0�����\�����rr)rrrr)-�
__future__r�logging�os.pathr3r�r��urllib.parser��urllib.request�dataclassesr�typingr�pip._internal.exceptionsrr�pip._internal.utils.miscrr	r
�pip._internal.utils.subprocessr� pip._internal.vcs.versioncontrolrr
rrrrr�parser�r��	getLoggerr�rN�compilerMr�VERBOSEr�rr�registerr(rr�<module>r�s���"�"�"�"�"�"�������������	�	�	�	���������������������B�B�B�B�B�B�B�B�G�G�G�G�G�G�G�G�G�G�7�7�7�7�7�7��������������������<� ��
�\�
$�
�
��	�8�	$�	$���B�J������R�Z�+�
,�
,�
�
�B�J�		��J�
�
�	�'�'�'�'�z�z�z�z�z�.�z�z�z�z
���S�����r
Back to Directory File Manager