<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet"
        integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/all.min.css"
        integrity="sha512-SzlrxWUlpfuzQ+pcUCosxcglQRNAq/DZjVsC0lE40xsADsfeQoEypE+enwcOiGjk/bSuGGKHEyjSoQ1zVisanQ=="
        crossorigin="anonymous" referrerpolicy="no-referrer" />
</head>
</html>
U
    .e 5                     @   s  d dl mZ d dlZd dlZd dlZd dlmZ d dl	mZ
 d dl	mZ d dlmZ d dlmZ d dlmZ d dlmZ d d	lmZ d d
lmZmZmZmZ erd dlmZmZ d dlmZ d dlm Z m!Z! e
j"Z"e
j#Z#e$e%Z&e'dZ(dd Z)G dd deZ*e+e* dS )    )absolute_importN)parse)request)
BadCommand)display_path)make_command)TempDirectory)MYPY_CHECK_RUNNING)RemoteNotFoundErrorVersionControl!find_path_to_setup_from_repo_rootvcs)OptionalTuple)
HiddenText)AuthInfo
RevOptionsz^[a-fA-F0-9]{40}$c                 C   s   t t| S N)bool
HASH_REGEXmatch)sha r   9/usr/lib/python3.8/site-packages/pip/_internal/vcs/git.pylooks_like_hash*   s    r   c                       s   e Zd ZdZdZdZdZdZdZe	dd Z
d	d
 Zedd Zdd Zedd Zedd Zedd Zdd Zdd Zdd Zedd Zed(ddZed d! Ze fd"d#Zed$d% Ze fd&d'Z  ZS ))Gitgitz.gitclone)r   zgit+httpz	git+httpszgit+sshzgit+gitzgit+file)ZGIT_DIRZGIT_WORK_TREEHEADc                 C   s   | gS r   r   revr   r   r   get_base_rev_args:   s    zGit.get_base_rev_argsc                 C   s\   d}| j dgdd}||r8|t|d   d }nd}d|dd d }t|S )	Nzgit version versionF)show_stdoutr    .   )run_command
startswithlensplitjoinparse_version)selfZVERSION_PFXr"   r   r   r   get_git_version>   s    
zGit.get_git_versionc                 C   sB   dddg}| j |dd|d}| }|dr>|tdd S dS )	zl
        Return the current branch, or None if HEAD isn't at a branch
        (e.g. detached HEAD).
        zsymbolic-ref-qr      FZextra_ok_returncodesr#   cwdzrefs/heads/N)r'   stripr(   r)   )clslocationargsoutputrefr   r   r   get_current_branchK   s    

   
zGit.get_current_branchc              	   C   sX   | ds|d }tdd2}| j|j|d | jdddd|gd	|jd
 W 5 Q R X dS )z@Export the Git repository at the url to the destination location/export)Zkind)urlzcheckout-indexz-az-fz--prefixFr#   r3   N)endswithr   unpackpathr'   )r-   r6   r=   Ztemp_dirr   r   r   r<   `   s    
 z
Git.exportc           
   	   C   s   | j d|g|ddd}i }| dD ]V}|d}|s<q(z|jddd	\}}W n" tk
rt   td
|Y nX |||< q(d|}d|}	||}|dk	r|dfS ||	}|dfS )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.
        zshow-refFignore)r3   r#   on_returncode
    )maxsplitzunexpected show-ref line: {!r}zrefs/remotes/origin/{}zrefs/tags/{}NT)r'   r4   r*   rstrip
ValueErrorformatget)
r5   destr    r8   Zrefsliner   r9   Z
branch_refZtag_refr   r   r   get_revision_sham   s*     





zGit.get_revision_shac                 C   s   |j }| ||\}}|dk	r:||}|r0|nd|_|S t|sNtd| |ds\|S | jt	dd||
 |d | j|d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.
        Nz:Did not find branch or tag '%s', assuming revision or ref.zrefs/fetchr/   r3   Z
FETCH_HEADr   )Zarg_revrO   Zmake_newbranch_namer   loggerZwarningr(   r'   r   to_argsget_revision)r5   rM   r=   rev_optionsr    r   Z	is_branchr   r   r   resolve_revision   s(    



zGit.resolve_revisionc                 C   s   |sdS |  ||kS )z
        Return whether the current commit hash equals the given name.

        Args:
          dest: the repository directory.
          name: a string name.
        F)rU   )r5   rM   namer   r   r   is_commit_id_equal   s    	zGit.is_commit_id_equalc                 C   s   |  }td||t| | tdd|| |jr| |||}t|dd }|d kr| 	||jstdd|
 }| j||d n4| ||krd|}dd|d	|g}| j||d | | d S )
NzCloning %s%s to %sr   r/   rR   checkoutrQ   z	origin/{}z-bz--track)Z
to_displayrS   infor   r'   r   r    rW   getattrrY   rT   r:   rK   update_submodules)r-   rM   r=   rV   Zrev_displayrR   cmd_argsZtrack_branchr   r   r   	fetch_new   s0      
    zGit.fetch_newc                 C   sB   | j tdd||d tdd| }| j ||d | | d S )Nconfigzremote.origin.urlrQ   rZ   r/   )r'   r   rT   r]   r-   rM   r=   rV   r^   r   r   r   switch   s    
z
Git.switchc                 C   st   |   tdkr&| jdddg|d n| jddg|d | |||}tddd| }| j||d | | d S )Nz1.9.0rP   r/   z--tagsrQ   resetz--hard)r.   r,   r'   rW   r   rT   r]   ra   r   r   r   update   s    z
Git.updatec                 C   sx   | j dddgdd|d}| }z|d }W n tk
rD   tY nX |D ]}|drJ|} qbqJ|d	d
 }| S )z
        Return URL of the first remote encountered.

        Raises RemoteNotFoundError if the repository does not have a remote
        url configured.
        r`   z--get-regexpzremote\..*\.urlr0   Fr2   r   zremote.origin.url rF   r1   )r'   
splitlines
IndexErrorr
   r(   r*   r4   )r5   r6   stdoutZremotesZfound_remoteZremoter=   r   r   r   get_remote_url
  s"    
  

zGit.get_remote_urlNc                 C   s(   |d krd}| j d|gd|d}| S )Nr   	rev-parseFr>   )r'   r4   )r5   r6   r    Zcurrent_revr   r   r   rU   %  s      zGit.get_revisionc                 C   sR   | j ddgd|d }tj|s2tj||}tjtj|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.
        ri   z	--git-dirFr>   z..)r'   r4   osrA   isabsr+   abspathr   )r5   r6   Zgit_dirZ	repo_rootr   r   r   get_subdirectory.  s     
zGit.get_subdirectoryc                    s   t |\}}}}}|dr|dt|d  }|t|ddd }t|||||f}|dd }	|d|	 t||	d ||||f }d|kr|dd	}t	t
| |\}}
}|d
d}nt	t
| |\}}
}||
|fS )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;   \+r1   z://zgit+z
git+ssh://zssh://r$   )urlsplitr?   r)   lstripurllib_requestZurl2pathnamereplace
urlunsplitfindsuperr   get_url_rev_and_auth)r5   r=   ZschemeZnetlocrA   ZqueryZfragmentinitial_slashesnewpathZ
after_plusr    Z	user_pass	__class__r   r   rx   =  s.    

 zGit.get_url_rev_and_authc                 C   s6   t jt j|dsd S | jdddddg|d d S )Nz.gitmodulesZ	submodulerd   z--initz--recursiver/   rQ   )rj   rA   existsr+   r'   )r5   r6   r   r   r   r]   `  s    zGit.update_submodulesc                    sZ   t t| |rdS z| jdg|dddd}| W S  tk
rT   td| Y dS X d S )NTri   FrB   )r3   r#   rC   Zlog_failed_cmdzKcould not determine if %s is under git control because git is not available)rw   r   controls_locationr'   r   rS   debug)r5   r6   rr{   r   r   r~   i  s    zGit.controls_location)N)__name__
__module____qualname__rX   dirnameZ	repo_nameZschemesZunset_environZdefault_arg_revstaticmethodr!   r.   classmethodr:   r<   rO   rW   rY   r_   rb   rd   rh   rU   rm   rx   r]   r~   __classcell__r   r   r{   r   r   .   sB   


(
,


"
r   ),Z
__future__r   ZloggingZos.pathrj   reZpip._vendor.packaging.versionr   r,   Zpip._vendor.six.moves.urllibZurllib_parser   rs   Zpip._internal.exceptionsr   Zpip._internal.utils.miscr   Zpip._internal.utils.subprocessr   Zpip._internal.utils.temp_dirr   Zpip._internal.utils.typingr	   Z pip._internal.vcs.versioncontrolr
   r   r   r   typingr   r   r   r   r   rq   ru   Z	getLoggerr   rS   compiler   r   r   registerr   r   r   r   <module>   s2   

  N