Viewing File: /usr/lib/python3.6/site-packages/pip/vcs/__pycache__/git.cpython-36.pyc

3

ajf-@sddlmZddlZddlZddlZddlmZddlm	Z	ddl
mZddl
m
ZddlmZddlmZmZddlmZmZejZejZejeZGd	d
d
eZejedS))absolute_importN)samefile)
BadCommand)parse)request)display_pathrmtree)vcsVersionControlcseZdZdZdZdZd7Zd8fd
d	Zdd
ZddZ	ddZ
ddZddZddZ
ddZddZddZd9dd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd:d+d,Zd-d.Zd/d0Zfd1d2Zd3d4Zefd5d6ZZS);Gitgitz.gitclonegit+http	git+httpsgit+sshgit+gitgit+fileNcs|rt|\}}}}}|jdr|dt|jd}	|	tj|jddjd}
t|||
||f}|jdd}|d|t||d||
||f}t	t
|j|f||dS)Nfile/\+)urlsplitendswithlenlstripurllib_requestZurl2pathnamereplace
urlunsplitfindsuperr__init__)selfurlargskwargsschemeZnetlocpathZqueryZfragmentinitial_slashesnewpathZ
after_plus)	__class__/usr/lib/python3.6/git.pyr! s

zGit.__init__cCsTd}|jdgdd}|j|r0|t|d}nd}dj|jddd}t|S)Nzgit version versionF)show_stdout.)run_command
startswithrjoinsplit
parse_version)r"ZVERSION_PFXr-r+r+r,get_git_version5s
zGit.get_git_versioncCsVtjdd}|j|z0|jds*|d}|jdddd|gd|d	Wd
t|Xd
S)z@Export the Git repository at the url to the destination locationz-exportzpip-rzcheckout-indexz-az-fz--prefixF)r.cwdN)tempfileZmkdtempunpackrr2r)r"locationZtemp_dirr+r+r,exportBs

z
Git.exportcCsL|j||}d|}||kr&||gS||kr8||gStjd||SdS)zCheck 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_refsloggerwarning)r"revdestrev_optionsZ	revisionsZ
origin_revr+r+r,check_rev_optionsOs

zGit.check_rev_optionscCs|j|j|dS)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"rArBr+r+r,
check_versioncszGit.check_versioncCs8|jdd|g|d|jddg||d|j|dS)Nconfigzremote.origin.url)r8checkoutz-q)r2update_submodules)r"rAr#rBr+r+r,switchlsz
Git.switchcCst|jtdkr&|jdddg|dn|jddg|d|rN|j|d||}|jdddg||d|j|dS)	Nz1.9.0Zfetchz-qz--tags)r8rresetz--hard)r7r6r2rCrH)r"rArBr+r+r,updatersz
Git.updatecCs|j\}}|r |g}d|}n
dg}d}|j||||rtjd||t||jdd||g|r|j|||}|j||s|jddg||d|j|dS)	Nz (to %s)z
origin/masterr/zCloning %s%s to %sr
z-qrG)r8)	get_url_revZcheck_destinationr>inforr2rCrErH)r"rAr#r@rBZrev_displayr+r+r,obtains"

z
Git.obtaincCsZ|jdddgd|d}|j}|d}x|D]}|jdr,|}Pq,W|jdd	}|jS)
z+Return URL of the first remote encountered.rFz--get-regexpzremote\..*\.urlF)r.r8rzremote.origin.url  r)r2
splitlinesr3r5strip)r"r;ZremotesZfound_remoteZremoter#r+r+r,get_urls


zGit.get_urlcCs|jddgd|d}|jS)Nz	rev-parseZHEADF)r.r8)r2rQ)r"r;current_revr+r+r,rDszGit.get_revisionr/ccs|jd|gd|dd}xl|jdD]^}|jd}|s6q"y|jdd\}}Wn"tk
rltd	|YnX|j|jfVq"Wd
S)z4Yields tuples of (commit, ref) for branches and tagszshow-refFignore)r.r8
on_returncode

rOrzunexpected show-ref line: N)r2r5rstrip
ValueErrorrQ)r"r;patternoutputlinecommitrefr+r+r,
get_full_refss

zGit.get_full_refscCs
|jdS)Nz
refs/remotes/)r3)r"r^r+r+r,
is_ref_remoteszGit.is_ref_remotecCs
|jdS)Nzrefs/heads/)r3)r"r^r+r+r,
is_ref_branchszGit.is_ref_branchcCs
|jdS)Nz
refs/tags/)r3)r"r^r+r+r,
is_ref_tagszGit.is_ref_tagcCs"t|j||j||j|fS)z0A ref is a commit sha if it is not anything else)anyr`rarb)r"r^r+r+r,
is_ref_commitszGit.is_ref_commitcCs
|j|S)N)r=)r"r;r+r+r,get_refsszGit.get_refscCsi}x~|j||D]n\}}d}|j|r:|tdd}n6|j|rV|tdd}n|j|rp|tdd}|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`rrarb)r"r;rZrvr]r^Zref_namer+r+r,r=s


zGit.get_short_refscCs|jddgd|dj}tjj|s2tjj||}tjj|d}|}xBtjjtjj|ds|}tjj|}||krFtj	d|dSqFWt
||rdStjj||S)	z:Return the relative path of setup.py to the git repo root.z	rev-parsez	--git-dirF)r.r8z..zsetup.pyzGCould not find setup.py for directory %s (tried all parent directories)N)r2rQosr'isabsr4existsdirnamer>r?rrelpath)r"r;Zgit_dirZroot_dirZ
orig_locationZ
last_locationr+r+r,_get_subdirectorys"

zGit._get_subdirectorycCsr|j|}|jjds d|}|jjddd}|s<dS|j|}d|||f}|j|}|rn|d|7}|S)Nzgit:zgit+-rrz%s@%s#egg=%sz&subdirectory=)rRlowerr3Zegg_namer5rDrl)r"Zdistr;ZrepoZegg_project_namerSZreqZsubdirectoryr+r+r,get_src_requirements


zGit.get_src_requirementcsbd|jkrHd|jkst|jjdd|_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#AssertionErrorrr rrL)r"r#r@)r*r+r,rLs
zGit.get_url_revcCs6tjjtjj|dsdS|jdddddg|ddS)Nz.gitmodulesZ	submodulerKz--initz--recursivez-q)r8)rgr'rir4r2)r"r;r+r+r,rHs
zGit.update_submodulescsVtt|j|rdSy|jdg|ddd}|Stk
rPtjd|dSXdS)NTz	rev-parseFrT)r8r.rUzKcould not determine if %s is under git control because git is not available)r rcontrols_locationr2rr>debug)clsr;r)r*r+r,rq%s
zGit.controls_location)rrrrrr)N)r/)r/)__name__
__module____qualname__namerjZ	repo_nameZschemesr!r7r<rCrErIrKrNrRrDr_r`rarbrdrer=rlrorLrHclassmethodrq
__classcell__r+r+)r*r,rs4

	
	
r)Z
__future__rZloggingr9Zos.pathrgZ
pip.compatrZpip.exceptionsrZpip._vendor.six.moves.urllibrZurllib_parserrZpip._vendor.packaging.versionr6Z	pip.utilsrrZpip.vcsr	r
rrZ	getLoggerrur>rregisterr+r+r+r,<module>s"

Back to Directory File Manager