U .e5@sddlmZddlZddlZddlZddlmZddl mZ ddl m Z ddl mZddlmZddlmZddlmZdd lmZdd lmZmZmZmZerdd lmZmZdd lmZdd lm Z m!Z!e j"Z"e j#Z#e$e%Z&e'dZ(ddZ)GdddeZ*e+e*dS))absolute_importN)parse)request) BadCommand) display_path) make_command) TempDirectory)MYPY_CHECK_RUNNING)RemoteNotFoundErrorVersionControl!find_path_to_setup_from_repo_rootvcs)OptionalTuple) HiddenText)AuthInfo RevOptionsz^[a-fA-F0-9]{40}$cCstt|SN)bool HASH_REGEXmatch)shar9/usr/lib/python3.8/site-packages/pip/_internal/vcs/git.pylooks_like_hash*srcseZdZdZdZdZdZdZdZe ddZ d d Z e d d Z d dZe ddZe ddZe ddZddZddZddZe ddZe d(ddZe d d!Ze fd"d#Ze d$d%Ze fd&d'ZZS))Gitgitz.gitclone)rzgit+httpz git+httpszgit+sshzgit+gitzgit+file)ZGIT_DIRZ GIT_WORK_TREEHEADcCs|gSrrrevrrrget_base_rev_args:szGit.get_base_rev_argscCs\d}|jdgdd}||r8|t|dd}nd}d|ddd}t|S) Nz git version versionF) show_stdoutr.) run_command startswithlensplitjoin parse_version)selfZ VERSION_PFXr"rrrget_git_version>s zGit.get_git_versioncCsBdddg}|j|dd|d}|}|dr>|tddSdS) zl Return the current branch, or None if HEAD isn't at a branch (e.g. detached HEAD). z symbolic-ref-qrFZextra_ok_returncodesr#cwdz refs/heads/N)r'stripr(r))clslocationargsoutputrefrrrget_current_branchKs  zGit.get_current_branchc CsX|ds|d}tdd2}|j|j|d|jdddd|gd |jd W5QRXd S) z@Export the Git repository at the url to the destination location/export)Zkind)urlzcheckout-indexz-az-fz--prefixFr#r3N)endswithrunpackpathr')r-r6r=Ztemp_dirrrrr<`s   z Git.exportc Cs|jd|g|ddd}i}|dD]V}|d}|s)r'r4)r5r6r Z current_revrrrrV%szGit.get_revisioncCsR|jddgd|d}tj|s2tj||}tjtj|d}t||S)z~ Return the path to setup.py, relative to the repo root. Return None if setup.py is in the repo root. rjz --git-dirFr>z..)r'r4osrAisabsr+abspathr )r5r6Zgit_dirZ repo_rootrrrget_subdirectory.s  zGit.get_subdirectoryc st|\}}}}}|dr|dt|d }|t|ddd}t|||||f}|dd} |d| t|| d||||f}d|krd|kst |d d }t t | |\}} } |d d }nt 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. fileNr;\+r1z://zfile:zgit+z git+ssh://zssh://r$) urlsplitr?r)lstripurllib_requestZ url2pathnamereplace urlunsplitfindrRsuperrget_url_rev_and_auth) r5r=ZschemeZnetlocrAZqueryZfragmentinitial_slashesnewpathZ after_plusr Z user_pass __class__rrry=s0      zGit.get_url_rev_and_authcCs6tjtj|dsdS|jdddddg|ddS)Nz .gitmodulesZ submodulerez--initz --recursiver/rQ)rkrAexistsr+r')r5r6rrrr^`s  zGit.update_submodulescsZtt||rdSz|jdg|dddd}| WStk rTtd|YdSXdS)NTrjFrB)r3r#rCZlog_failed_cmdzKcould not determine if %s is under git control because git is not available)rxrcontrols_locationr'rrTdebug)r5r6rr|rrriszGit.controls_location)N)__name__ __module__ __qualname__rYdirnameZ repo_nameZschemesZ unset_environZdefault_arg_rev staticmethodr!r. classmethodr:r<rOrXrZr`rcrerirVrnryr^r __classcell__rrr|rr.sB     ( ,     " r),Z __future__rZloggingZos.pathrkreZpip._vendor.packaging.versionrr,Zpip._vendor.six.moves.urllibZ urllib_parserrtZpip._internal.exceptionsrZpip._internal.utils.miscrZpip._internal.utils.subprocessrZpip._internal.utils.temp_dirrZpip._internal.utils.typingr Z pip._internal.vcs.versioncontrolr r r r typingrrrrrrrrvZ getLoggerrrTcompilerrrregisterrrrrs2            N