Edit File: git.cpython-36.pyc
3 )�]b,-������������������@���s����d�dl�mZ�d�dlZd�dlZd�dlZd�dlmZ�d�dlm Z �d�dl mZ�d�dl m Z�d�dlmZ�d�dlmZmZ�d�dlmZmZ�ejZejZeje�ZG�d d ��d e�Zeje��dS�)�����)�absolute_importN)�samefile)� BadCommand)�parse)�request)�display_path�rmtree)�vcs�VersionControlc�������������������s����e�Zd�ZdZdZdZd7Zd8��fd d� Zdd ��Zdd��Z dd��Z dd��Zdd��Zdd��Z dd��Zdd��Zdd��Zd9dd �Zd!d"��Zd#d$��Zd%d&��Zd'd(��Zd)d*��Zd:d+d,�Zd-d.��Zd/d0��Z��fd1d2�Zd3d4��Ze��fd5d6��Z���ZS�);�Git�gitz.git�clone�git+http� git+https�git+ssh�git+git�git+fileNc����������������s����|r�t�|�\}}}}}|jd�r�|d�t|jd�����} | tj|�jdd�jd��} t||| ||f�}|jd�d�}|d�|��t||d���|| ||f��}t t |��j|f|�|��d�S�)N�file�/�\�+����)�urlsplit�endswith�len�lstrip�urllib_requestZurl2pathname�replace� urlunsplit�find�superr����__init__)�self�url�args�kwargs�schemeZnetloc�pathZqueryZfragment�initial_slashes�newpathZ after_plus)� __class__���/usr/lib/python3.6/git.pyr!��� ���s���� zGit.__init__c�������������C���sT���d}|�j�dgdd�}|j|�r0|t|�d���}nd}dj|jd�d�d���}t|�S�)Nzgit version �versionF)�show_stdout���.����)�run_command� startswithr����join�split� parse_version)r"���ZVERSION_PFXr-���r+���r+���r,����get_git_version5���s���� zGit.get_git_versionc�������������C���sV���t�jdd�}|�j|��z0|jd�s*|d�}|�jdddd|gd|d ��W�d t|��X�d S�)z@Export the Git repository at the url to the destination locationz-exportzpip-r���zcheckout-indexz-az-fz--prefixF)r.����cwdN)�tempfileZmkdtemp�unpackr���r2���r���)r"����locationZtemp_dirr+���r+���r,����exportB���s���� z Git.exportc�������������C���sL���|�j�||�}d|�}||kr&||�gS�||kr8||�gS�tjd|��|S�dS�)z�Check the revision options before checkout to compensate that tags and branches may need origin/ as a prefix. Returns the SHA1 of the branch or tag if found. z origin/%sz5Could not find a tag or branch '%s', assuming commit.N)�get_short_refs�logger�warning)r"����rev�dest�rev_optionsZ revisionsZ origin_revr+���r+���r,����check_rev_optionsO���s���� zGit.check_rev_optionsc�������������C���s���|�j�|�j|d��S�)a �� Compare the current sha to the ref. ref may be a branch or tag name, but current rev will always point to a sha. This means that a branch or tag will never compare as True. So this ultimately only matches against exact shas. r���)�get_revisionr3���)r"���rA���rB���r+���r+���r,���� check_versionc���s����zGit.check_versionc�������������C���s8���|�j�dd|g|d��|�j�ddg|�|d��|�j|��d�S�)N�configzremote.origin.url)r8����checkoutz-q)r2����update_submodules)r"���rA���r#���rB���r+���r+���r,����switchl���s����z Git.switchc�������������C���st���|�j���td�kr&|�jdddg|d��n|�jddg|d��|rN|�j|d�||�}|�jdddg|�|d��|�j|��d�S�) Nz1.9.0Zfetchz-qz--tags)r8���r����resetz--hard)r7���r6���r2���rC���rH���)r"���rA���rB���r+���r+���r,����updater���s����z Git.updatec�������������C���s����|�j���\}}|r |g}d|�}n dg}d}|�j||||�r�tjd||t|���|�jdd||g��|r�|�j|||�}|�j||�s�|�jddg|�|d��|�j|��d�S�) Nz (to %s)z origin/masterr/���zCloning %s%s to %sr ���z-qrG���)r8���) �get_url_revZcheck_destinationr>����infor���r2���rC���rE���rH���)r"���rA���r#���r@���rB���Zrev_displayr+���r+���r,����obtain����s"���� z Git.obtainc�������������C���sZ���|�j�dddgd|d�}|j��}|d�}x|D�]}|jd�r,|}P�q,W�|jd�d �}|j��S�) z+Return URL of the first remote encountered.rF���z--get-regexpzremote\..*\.urlF)r.���r8���r���zremote.origin.url � r���)r2���� splitlinesr3���r5����strip)r"���r;���ZremotesZfound_remoteZremoter#���r+���r+���r,����get_url����s���� zGit.get_urlc�������������C���s���|�j�ddgd|d�}|j��S�)Nz rev-parseZHEADF)r.���r8���)r2���rQ���)r"���r;����current_revr+���r+���r,���rD�������s����zGit.get_revisionr/���c�������������c���s����|�j�d|gd|d�}xl|jd�D�]^}|jd�}|s4q y|jdd�\}}W�n"�tk rj���td|����Y�nX�|j��|j��fV��q W�d S�) z4Yields tuples of (commit, ref) for branches and tagszshow-refF)r.���r8���� � rO���r���zunexpected show-ref line: N)r2���r5����rstrip� ValueErrorrQ���)r"���r;����pattern�output�line�commit�refr+���r+���r,���� get_full_refs����s���� zGit.get_full_refsc�������������C���s ���|j�d�S�)Nz refs/remotes/)r3���)r"���r\���r+���r+���r,���� is_ref_remote����s����zGit.is_ref_remotec�������������C���s ���|j�d�S�)Nzrefs/heads/)r3���)r"���r\���r+���r+���r,���� is_ref_branch����s����zGit.is_ref_branchc�������������C���s ���|j�d�S�)Nz refs/tags/)r3���)r"���r\���r+���r+���r,���� is_ref_tag����s����zGit.is_ref_tagc�������������C���s"���t�|�j|�|�j|�|�j|�f��S�)z0A ref is a commit sha if it is not anything else)�anyr^���r_���r`���)r"���r\���r+���r+���r,���� is_ref_commit����s����zGit.is_ref_commitc�������������C���s ���|�j�|�S�)N)r=���)r"���r;���r+���r+���r,����get_refs����s����zGit.get_refsc�������������C���s����i�}x~|�j�||�D�]n\}}d}|�j|�r:|td�d��}n6|�j|�rV|td�d��}n|�j|�rp|td�d��}|dk r|||<�qW�|S�)z=Return map of named refs (branches or tags) to commit hashes.Nz refs/remotes/zrefs/heads/z refs/tags/)r]���r^���r���r_���r`���)r"���r;���rX����rvr[���r\���Zref_namer+���r+���r,���r=�������s���� zGit.get_short_refsc�������������C���s����|�j�ddgd|d�j��}tjj|�s2tjj||�}tjj|d�}|}xBtjjtjj|d��s�|}tjj|�}||krFtj d|��dS�qFW�t ||�r�dS�tjj||�S�) z:Return the relative path of setup.py to the git repo root.z rev-parsez --git-dirF)r.���r8���z..zsetup.pyzGCould not find setup.py for directory %s (tried all parent directories)N)r2���rQ����osr'����isabsr4����exists�dirnamer>���r?���r����relpath)r"���r;���Zgit_dirZroot_dirZ orig_locationZ last_locationr+���r+���r,����_get_subdirectory����s"���� zGit._get_subdirectoryc�������������C���sr���|�j�|�}|j��jd�s d|�}|j��jdd�d�}|s<d�S�|�j|�}d|||f�}|�j|�}|rn|d|�7�}|S�)Nzgit:zgit+�-r���r���z%s@%s#egg=%sz&subdirectory=)rR����lowerr3���Zegg_namer5���rD���rj���)r"���Zdistr;���ZrepoZegg_project_namerS���ZreqZsubdirectoryr+���r+���r,����get_src_requirement����s���� zGit.get_src_requirementc����������������sb���d|�j�krHd|�j�kst�|�j�jdd�|�_�tt|��j��\}}|jdd�}ntt|��j��\}}||fS�)a;�� Prefixes stub URLs like 'user@hostname:user/repo.git' with 'ssh://'. That's required because although they use SSH they sometimes doesn'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. z://zfile:zgit+z git+ssh://zssh://r/���)r#����AssertionErrorr���r ���r���rL���)r"���r#���r@���)r*���r+���r,���rL�����s���� zGit.get_url_revc�������������C���s6���t�jjt�jj|d��sd�S�|�jdddddg|d��d�S�)Nz.gitmodulesZ submodulerK���z--initz--recursivez-q)r8���)re���r'���rg���r4���r2���)r"���r;���r+���r+���r,���rH�����s ����zGit.update_submodulesc����������������sV���t�t|��j|�rdS�y|���jdg|ddd�}|�S��tk rP���tjd|��dS�X�d�S�)NTz rev-parseF�ignore)r8���r.���Z on_returncodezKcould not determine if %s is under git control because git is not available)r ���r����controls_locationr2���r���r>����debug)�clsr;����r)r*���r+���r,���rp���$��s���� zGit.controls_location)r���r���r���r���r���r���)N)r/���)r/���)�__name__� __module__�__qualname__�namerh���Z repo_nameZschemesr!���r7���r<���rC���rE���rI���rK���rN���rR���rD���r]���r^���r_���r`���rb���rc���r=���rj���rm���rL���rH����classmethodrp���� __classcell__r+���r+���)r*���r,���r������s4��� r���)Z __future__r���Zloggingr9���Zos.pathre���Z pip.compatr���Zpip.exceptionsr���Zpip._vendor.six.moves.urllibr���Zurllib_parser���r���Zpip._vendor.packaging.versionr6���Z pip.utilsr���r���Zpip.vcsr ���r ���r���r���Z getLoggerrt���r>���r����registerr+���r+���r+���r,����<module>���s"��� ��