관리-도구
편집 파일: git.cpython-39.pyc
a ����[��f�E����������������������@���s��d�dl�Z�d�dlZd�dlZd�dlZd�dlZd�dlZd�dlm Z m Z mZ�d�dlm Z mZ�d�dlmZmZmZ�d�dlmZ�d�dlmZmZmZmZmZmZmZ�ejjZejjZe�� e!�Z"e�#d�Z$e�#d�Z%e�#d ej&�Z'e(e)d �dd�Z*G�d d��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�returnc�����������������C���s���t�t�|���S��N)�bool� HASH_REGEX�match)r�����r����9/usr/lib/python3.9/site-packages/pip/_internal/vcs/git.py�looks_like_hash7���s����r���c�����������������������s��e�Zd�ZdZdZdZdZdZdZe e ee �d�dd ��Ze e e d �dd�Zeed f�d�dd�Zee ee �d�dd��Zee e eee �e f�d�dd��Zee e e d�dd��Zee eeed�dd��Zee ee �e d�dd��Ze eedd�d d!�Ze eedd�d"d#�Ze eedd�d$d%�Zee e d�d&d'��Ze e e d(�d)d*��Zee e e d+�d,d-��Z ed;e ee �e d+�d.d/��Z!ee ee �d�d0d1��Z"ee ee ee �e#f�d(���fd2d3��Z$ee dd�d4d5��Z%ee ee �d���fd6d7��Z&e e e d8�d9d:��Z'���Z(S�)<�Git�gitz.git�clone)zgit+httpz git+httpszgit+sshzgit+gitzgit+file)ZGIT_DIRZ GIT_WORK_TREE�HEAD)�revr���c�����������������C���s���|�gS�r���r����r���r���r���r����get_base_rev_argsK���s����zGit.get_base_rev_args)�url�destr���c�����������������C���sJ���|���t|��\}}|jsdS�|��||j�s.dS�t|��||j�d��}|�S�)NFr���)Zget_url_rev_optionsr ���r����is_commit_id_equalr����get_revision_sha)�selfr"���r#����_�rev_optionsZis_tag_or_branchr���r���r����is_immutable_rev_checkoutO���s����zGit.is_immutable_rev_checkout.)r���c�����������������C���sF���|�j�dgddd�}t�|�}|s0t�d|��dS�tdd��|���D���S�) N�versionFT)�show_stdout�stdout_onlyzCan't parse git version: %sr���c�����������������s���s���|�]}t�|�V��qd�S�r���)�int)�.0�cr���r���r���� <genexpr>c��������z&Git.get_git_version.<locals>.<genexpr>)�run_command�GIT_VERSION_REGEXr����logger�warning�tuple�groups)r&���r*���r���r���r���r����get_git_version]���s���� zGit.get_git_version)�locationr���c�����������������C���sB���g�d�}|�j�|ddd|d�}|���}|�d�r>|td�d��S�dS�)zl Return the current branch, or None if HEAD isn't at a branch (e.g. detached HEAD). )zsymbolic-ref�-qr��������FT�Zextra_ok_returncodesr+���r,����cwdzrefs/heads/N)r2����strip� startswith�len)�clsr9����args�output�refr���r���r����get_current_branche���s���� � zGit.get_current_branch)r#���r���r���c�������������� ���C���s����|�j�d|g|dddd�}i�}|����d�D�]T}|�d�}|s>q*z|jdd d �\}}W�n �tyt���td|����Y�n0�|||<�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)r2���r?����split�rstrip� ValueError�get)rB���r#���r���rD���Zrefs�lineZref_shaZref_nameZ branch_refZtag_refr���r���r���r���r%���~���s0����� zGit.get_revision_shac�����������������C���s.���|��d�rdS�t|�sdS�|��||�r*dS�dS�)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)rB���r#���r���r���r���r���� _should_fetch����s���� zGit._should_fetch)r#���r"���r(���r���c�����������������C���s����|j�}|dusJ��|��||�\}}|durF|�|�}|r<|nd|_|S�t|�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.�fetchr:����r>���Z FETCH_HEADr ���)Zarg_revr%����make_new�branch_namer���r4���r5���rT���r2���r ����to_args�get_revision)rB���r#���r"���r(���r���r���Z is_branchr���r���r����resolve_revision����s*���� �� zGit.resolve_revision)r#����namer���c�����������������C���s���|sdS�|���|�|kS�)z� Return whether the current commit hash equals the given name. Args: dest: the repository directory. name: a string name. F)rZ���)rB���r#���r\���r���r���r���r$�������s���� zGit.is_commit_id_equalNc����������� ������C���s ��|����}t�d||t|���|����dkr@|��tddd||���n|��tdd||���|jr�|��|||�}t |dd��}t� d||��|d�u�r�|��||j�s�tdd|����}|�j||d ��n4|�� |�|kr�d |���}dd|d|g}|�j||d ��n|��|�}|�|�}t�d ||j��|��|��d�S�)NzCloning %s%s to %s)rL�������r���z--filter=blob:noner:���rX���zRev options %s, branch_name %s�checkoutrV���zorigin/z-bz--trackzResolved %s to commit %s)Z to_displayr4����infor���r8���r2���r ���r���r[����getattr�debugr$���rY���rF���rZ���rW����update_submodules) r&���r#���r"���r(���Zrev_displayrX����cmd_argsZtrack_branchr���r���r���r���� fetch_new���sL������ � � z Git.fetch_newc�����������������C���sB���|�j�tdd|�|d��tdd|����}|�j�||d��|��|��d�S�)N�configzremote.origin.urlrV���r^���r:���)r2���r ���rY���rb����r&���r#���r"���r(���rc���r���r���r����switch7��s���� �z Git.switchc�����������������C���sn���|�����dkr |�jg�d�|d��n|�jddg|d��|��|||�}tddd|����}|�j||d��|��|��d�S�)N)r<���� ���)rU���r:���z--tagsrV���rU���r:����resetz--hard)r8���r2���r[���r ���rY���rb���rf���r���r���r����updateA��s����z Git.updatec�����������������C���s|���|�j�g�d�ddd|d�}|���}z|d�}W�n�tyB���t�Y�n0�|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. )re���z--get-regexpzremote\..*\.urlr;���FTr=���r���zremote.origin.url rK���r<���)r2���� splitlines� IndexErrorr���r@���rN����_git_remote_to_pip_urlr?���)rB���r9����stdoutZremotesZfound_remoteZremoter"���r���r���r����get_remote_urlO��s$���� � zGit.get_remote_url)r"���r���c�����������������C���sN���t��d|��r|�S�tj�|��r*t�|�����S�t�|��}|rB|� d�S�t |���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_matchr���r���r���rm���m��s���� zGit._git_remote_to_pip_url)r9���r���r���c�����������������C���s>���z |�j�dddd|�g|dd��W�n�ty4���Y�dS�0�dS�dS�) zU Check if rev is a commit that is available in the local repository. � rev-parser:���z--verifyzsha^F)r>����log_failed_cmdTN)r2���r���)rB���r9���r���r���r���r���rS������s����� zGit.has_commitc�����������������C���s*���|d�u�rd}|�j�d|gdd|d�}|���S�)Nr���ry���FT�r+���r,���r>���)r2���r?���)rB���r9���r���Zcurrent_revr���r���r���rZ������s�����zGit.get_revisionc�����������������C���sT���|�j�ddgdd|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. ry���z --git-dirFTr{���z..)r2���r?���rq���rr����isabs�join�abspathr���)rB���r9���Zgit_dirZ repo_rootr���r���r����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�/�\�+r<���z://zfile:zgit+z git+ssh://zssh://��)�urlsplit�endswithrA����lstrip�urllibZrequestZurl2pathname�replace�find� urlunsplit�super�get_url_rev_and_auth)rB���r"����scheme�netlocrr����query�fragment�initial_slashes�newpathZ after_plusr���Z user_pass�� __class__r���r���r�������s&���� ���zGit.get_url_rev_and_authc�����������������C���s0���t�j�t�j�|d��sd�S�|�jg�d�|d��d�S�)Nz.gitmodules)Z submodulerj���z--initz--recursiver:���rV���)rq���rr���rs���r}���r2���)rB���r9���r���r���r���rb������s�����zGit.update_submodulesc��������������������sx���t����|�}|r|S�z|�jddg|ddddd�}W�n2�tyR���t�d|��Y�d�S��tyd���Y�d�S�0�tj� |� d��S�) Nry���z--show-toplevelFT�raise)r>���r+���r,���rH���rz���zKcould not determine if %s is under git control because git is not availablez )r�����get_repository_rootr2���r���r4���ra���r���rq���rr����normpathrO���)rB���r9����loc�rr����r���r���r�������s*����� �zGit.get_repository_root)�repo_urlr���c�����������������C���s���dS�)zEIn either https or ssh form, requirements must be prefixed with git+.Tr���)r����r���r���r����should_add_vcs_url_prefix���s����zGit.should_add_vcs_url_prefix)N))�__name__� __module__�__qualname__r\����dirnameZ repo_nameZschemesZ unset_environZdefault_arg_rev�staticmethod�strr���r!���r���r)���r���r-���r8����classmethodr���rF���r%���rT���r���r���r[���r$���rd���rg���rj���ro���rm���rS���rZ���r���r���r����rb���r����r����� __classcell__r���r���r����r���r���;���sV��� -�-7 $r���)-ZloggingZos.pathrq���rt���rp����urllib.parser����Zurllib.request�typingr���r���r���Zpip._internal.exceptionsr���r���Zpip._internal.utils.miscr���r���r ���Zpip._internal.utils.subprocessr ���Z pip._internal.vcs.versioncontrolr���r���r ���r���r���r���r����parser����r����Z getLoggerr����r4����compiler3���r����VERBOSErw���r����r���r���r����registerr���r���r���r����<module>���s6���$ � ����I