7fGddlZddlZddlZddlZddlZddlZddlm Z ddl m Z m Z m Z ddlmZmZddlmZmZmZddlmZddlmZmZmZmZmZmZmZejj Z ejj!Z!ej"e#Z$ej%dZ&ej%d Z'ej%d ej(Z)d e*d e+fd Z,GddeZ-ej.e-dS)N)replace)ListOptionalTuple) BadCommandInstallationError) HiddenText display_pathhide_url) make_command)AuthInfoRemoteNotFoundErrorRemoteNotValidError RevOptionsVersionControl(find_path_to_project_root_from_repo_rootvcsz(^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[^:]*) $shareturncPtt|SN)bool HASH_REGEXmatch)rs u/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib/python3.11/site-packages/pip/_internal/vcs/git.pylooks_like_hashr8s    %% & &&c 0eZdZdZdZdZdZdZdZe de de e fd Z d e d e de fd Zdeed ffdZede dee fdZed e de deee e ffdZed e de de fdZed e d ededefdZed e dee de fdZd e d edededdf dZd e d ededdfdZd e d ededdfdZede de fdZe d e de fdZede de de fdZ ed&de dee de fdZ!ede dee fd Z"ed e dee ee e#fffd! Z$ede ddfd"Z%ede dee ffd# Z&e d$e de fd%Z'xZ(S)'Gitgitz.gitclone)zgit+httpz git+httpszgit+sshzgit+gitzgit+file)GIT_DIR GIT_WORK_TREEHEADrevrc|gSrr%s rget_base_rev_argszGit.get_base_rev_argsLs u rurldestc|t|\}}|jsdS|||jsdSt |||jd}| S)NFr)get_url_rev_optionsr r%is_commit_id_equalrget_revision_sha)selfr*r+_ rev_optionsis_tag_or_branchs ris_immutable_rev_checkoutzGit.is_immutable_rev_checkoutPs11(3--@@; 5&&t[_== 5  5 5dKO L LQ OPP###r.c0|dgddd}t|}|std|dSt |dt |d fS) Nversionz git versionFT) command_desc show_stdout stdout_onlyzCan't parse git version: %sr') run_commandGIT_VERSION_REGEXrloggerwarningintgroup)r0r6rs rget_git_versionzGit.get_git_version^s"" K& #   "''00  NN8' B B B2EKKNN##SQ%8%899rlocationcgd}||ddd|}|}|dr|tddSdS)zl Return the current branch, or None if HEAD isn't at a branch (e.g. detached HEAD). )z symbolic-ref-qr$r:FTextra_ok_returncodesr8r9cwdz refs/heads/N)r<strip startswithlen)clsrCargsoutputrefs rget_current_branchzGit.get_current_branchksw.-- !% !  llnn >>- ( ( -s=))++, ,trc|d|g|ddd}i}|dD][}|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-refFTignore)rIr8r9 on_returncode   r;)maxsplitzunexpected show-ref line: zrefs/remotes/origin/z refs/tags/)r<rJsplitrstrip ValueErrorget) rMr+r%rOrefslineref_sharef_name branch_reftag_refrs rr/zGit.get_revision_shas6  " !  LLNN((.. % %D;;t$$D  H$(JJsQJ$?$?! H H H!!Fd!F!FGGG H %DNN1C11 $s$$hhz"" ?; hhwU|s !A<<Bc|drdSt|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)rKr has_commit)rMr+r%s r _should_fetchzGit._should_fetchsR >>' " " 4s## 5 >>$ $ $ 5trr2c |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.fetchrErI FETCH_HEADr() arg_revr/make_newrrr>r?rer<r to_args get_revision)rMr+r*r2r%r is_branchs rresolve_revisionzGit.resolve_revisions(!--dC88Y ?%..s33K!+9infor rBr<r r%rpgetattrdebugr.rmrQrnrlupdate_submodules) r0r+r*r2rs rev_displayflagsrgcmd_args track_branchrs r fetch_newz Git.fetch_newsW",,..  (#{L>%1EE !^^EE/E    ! !W , ,   (          \'EEE3EEEE F F F ? 4//c;GGK!+}dCCK LL9; T T T"..t[_EE9+"#++--  H $$X4$888((..+== 766    t 444##D))C%..s33K .[_EEE t$$$$$rc|tdd||tdd|}|||||dS)Nconfigzremote.origin.urlrirvrE)r<r rmr{r0r+r*r2r~s rswitchz Git.switchEs  #6 < <     D+2E2E2G2GHH t,,, t$$$$$rcj|dkr|gd|n|ddg|||||}tddd|}|||||dS)N)r: )rhrEz--tagsrirhrEresetz--hard)rBr<rpr rmr{rs rupdatez Git.updateOs    ! !V + +   666D  A A A A   gt_$  7 7 7++D#{CC 49L9L9N9NOO t,,, t$$$$$rc`|gdddd|}|} |d}n#t$rtwxYw|D]}|dr|}n|dd }||S) z Return URL of the first remote encountered. Raises RemoteNotFoundError if the repository does not have a remote url configured. )rz --get-regexpzremote\..*\.urlrFFTrGrzremote.origin.url rWr:)r< splitlines IndexErrorrrKrY_git_remote_to_pip_urlrJ)rMrCstdoutremotes found_remoteremoter*s rget_remote_urlzGit.get_remote_url]s : : :!% !  ##%% &"1:LL & & &% % &  F  !566 %    %%a())#))++666s ;A c:tjd|r|Stj|r&t j|St|}|r| dSt|)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) rerospathexistspathlibPurePathas_uri SCP_REGEXexpandr)r* scp_matchs rrzGit._git_remote_to_pip_url{s" 8Is # # J 7>>#   2#C((//11 1OOC((  6##$455 5!#&&&rch |dddd|zg|ddS#t$rYdSwxYw)zU Check if rev is a commit that is available in the local repository. rev-parserEz--verifyzsha^F)rIlog_failed_cmdT)r<r)rMrCr%s rrdzGit.has_commitsc  OOdJ =$    4!   55 s # 11ch|d}|d|gdd|}|S)Nr$rFTr8r9rI)r<rJ)rMrCr% current_revs rrnzGit.get_revisionsI ;Coo #  &    """rct|ddgdd|}tj|s tj||}tjtj|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. rz --git-dirFTrz..)r<rJrrisabsjoinabspathr)rMrCgit_dir repo_roots rget_subdirectoryzGit.get_subdirectorys// + & "  %''  w}}W%% 6gll8W55GGOOBGLL$$?$?@@ 7)LLLrct|\}}}}}|dr|dt|d }|tj|dddz}|ddz} |d| t|| d||||fz}d|vrXd|vsJ|d d }t |\}} } |d d }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/\+r:z://zfile:zgit+z git+ssh://zssh://) urlsplitendswithrLlstripurllibrequest url2pathnamerfind urlunsplitsuperget_url_rev_and_auth) rMr*schemenetlocrqueryfragmentinitial_slashesnewpath after_plusr% user_pass __class__s rrzGit.get_url_rev_and_authso19 -eX ??6 " " "#;c$++c*:*:&;&;%;#;">s"C"C Ci++h++CC"'''">">s"C"C CiC""rctjtj|dsdS|gd|dS)Nz .gitmodules) submodulerz--initz --recursiverEri)rrrrr<)rMrCs rr{zGit.update_submoduless^w~~bgll8]CCDD  F  B B B      rc`t|}|r|S |ddg|dddd}n8#t$rtd|YdSt $rYdSwxYwtj | dS) Nrz--show-toplevelFTraise)rIr8r9rTrzKcould not determine if %s is under git control because git is not availablez ) rget_repository_rootr<rr>rzrrrnormpathrZ)rMrClocrrs rrzGit.get_repository_rootsgg))(33  J /0! %$  AA    LL/    44    44 w 0 0111sA%A;. A;:A;repo_urlcdS)zEIn either https or ssh form, requirements must be prefixed with git+.Tr')rs rshould_add_vcs_url_prefixzGit.should_add_vcs_url_prefix s trr))__name__ __module__ __qualname__rqdirname repo_nameschemes unset_environdefault_arg_rev staticmethodstrrr)rr4rr@rB classmethodrrQr/rer rrpr.rrrrrrdrnrr rr{rr __classcell__)rs@rrr<sf DGIG1MOstCy\ $S $ $ $ $ $ $ :sCx : : : :#(3-[0+C+c+eHSM4compiler=rVERBOSErrrrrregisterr'rrrs ((((((((((BBBBBBBBGGGGGGGGGG777777 <  \ $   8 $ $BJ RZ+ , ,  BJ  J   ''''''PPPPP.PPPf  Sr