B Re6 @ s d dl mZ d dlZd dlZd dlZd dlmZ d dl mZ d dl mZ d dl mZmZ d dlmZmZ d dlmZ d dlmZ d d lmZ d d lmZmZmZmZ erd dlmZm Z d dlm!Z! d d lm"Z"m#Z# e j$Z$e j%Z%e&e'Z(e)dZ*dd Z+G dd deZ,e-e, dS ) )absolute_importN)parse)request) BadCommandSubProcessError)display_pathhide_url)make_command) TempDirectory)MYPY_CHECK_RUNNING)RemoteNotFoundErrorVersionControl!find_path_to_setup_from_repo_rootvcs)OptionalTuple) HiddenText)AuthInfo RevOptionsz^[a-fA-F0-9]{40}$c C s t t| S )N)bool HASH_REGEXmatch)sha r /builddir/build/BUILDROOT/alt-python37-pip-20.2.4-6.el8.x86_64/opt/alt/python37/lib/python3.7/site-packages/pip/_internal/vcs/git.pylooks_like_hash* s r c s e Zd ZdZdZdZdZdZdZe dd Z d d Zdd Ze d d Zdd Ze dd Ze dd Ze dd Zdd Zdd Zdd Ze dd Ze d*d d!Ze d"d# Ze fd$d%Ze d&d' Ze fd(d)Z ZS )+Gitgitz.gitclone)r zgit+httpz git+httpszgit+sshzgit+gitzgit+file)GIT_DIR GIT_WORK_TREEHEADc C s | gS )Nr )revr r r get_base_rev_args: s zGit.get_base_rev_argsc C sJ | t|\}}|jsdS | ||js.dS t| ||jd }| S )NFr )get_url_rev_optionsr r" is_commit_id_equalr get_revision_sha)selfurldest_rev_optionsis_tag_or_branchr r r is_immutable_rev_checkout> s zGit.is_immutable_rev_checkoutc C sX d}| dg}||r4|t|d d }nd}d|dd d }t|S )Nzgit version versionr . )run_command startswithlensplitjoin parse_version)r' VERSION_PFXr. r r r get_git_versionO s zGit.get_git_versionc C s@ dddg}| j |d|d}| }|dr<|tdd S dS )zl Return the current branch, or None if HEAD isn't at a branch (e.g. detached HEAD). zsymbolic-refz-qr! ) )extra_ok_returncodescwdzrefs/heads/N)r2 stripr3 r4 )clslocationargsoutputrefr r r get_current_branch\ s zGit.get_current_branchc C sV | ds|d }tdd0}| j|j|d | jdddd|g|jd W d Q R X d S )z@Export the Git repository at the url to the destination location/export)kind)r( zcheckout-indexz-az-fz--prefix)r<