
    \j	                    N    d Z ddlmZ ddlZddlZddZdd	ZddZddZddZ	dS )zGit utilities.    )annotationsNdirstrreturnboolc                |    t           j                            t           j                            | d                    S )z3Is the given directory version-controlled with git?.git)ospathexistsjoinr   s    L/var/www/app.qaans.com/backend/venv/lib/python3.11/site-packages/mypy/git.pyis_git_repor   
   s&    7>>"',,sF33444    c                 x    	 t          j        ddg           dS # t           j        $ r Y dS t          $ r Y dS w xY w)zCan we run the git executable?gitz--helpTF)
subprocesscheck_outputCalledProcessErrorOSError r   r   have_gitr      s`     1222t(   uu   uus    9	99bytesc                V    t          j        g d|                                           S )z.Get the SHA-1 of the HEAD of a git repository.)r   z	rev-parseHEADcwdr   r   stripr   s    r   git_revisionr!      s+    "#?#?#?SIIIOOQQQr   bytes | Nonec                   	 t           j                            | dd          }t          |d          5 }|                                                                }ddd           n# 1 swxY w Y   |                    d          r|dd         }t           j                            | dt          j        |                    }t           j                            |          rNt          |d          5 }|                                                                cddd           S # 1 swxY w Y   t           j                            | dd          }t           j                            |          rt          |d          5 }|D ]s}|                    d          r|                                	                                }t          |          d	k    r"|d
         |k    r|d         c cddd           S t	 ddd           n# 1 swxY w Y   dS t          |          dk    rt          d |D                       r|S dS # t          $ r Y dS w xY w)zGet the SHA-1 of HEAD by reading git files directly, without a subprocess.

    Returns None if the revision cannot be determined this way (e.g. unusual
    git state), in which case the caller should fall back to git_revision().
    r	   r   rbNs   ref:    zpacked-refs   #      r   (   c              3  8   K   | ]}t          |          d v V  dS )0123456789abcdefN)chr).0cs     r   	<genexpr>z-git_revision_no_subprocess.<locals>.<genexpr>;   s.      "N"NA3q66-?#?"N"N"N"N"N"Nr   )r
   r   r   openreadr    
startswithfsdecoder   splitlenallr   )	r   	head_pathfheadrefref_pathpacked_refs_pathlinepartss	            r   git_revision_no_subprocessr?      s   GLLff55	)T"" 	$a6688>>##D	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$??8$$ 	qrr(Cw||CS1A1ABBHw~~h'' ,(D)) ,Q6688>>++, , , , , , , , , , , , , , , ,  "w||CGGw~~.// ,*D11 ,Q ! , ,??400 %$ $

 2 2 4 4u::??uQx3#(8OO, , , , , , , ,,, , , , , , , , , , , , , , , 4t99??s"N"N"N"N"NNN?Kt   tts   1I 'A&I &A**I -A*.BI 3&D&I &D**I -D*.AI A)H*I 7H9I H		I H	I -I 
IIc                b    t          j        g d|           }|                                dk    S )z7Check whether a git repository has uncommitted changes.)r   statusz-unoz--porcelainr   r   r   )r   outputs     r   is_dirtyrC   B   s2    $%M%M%MSVWWWF<<>>S  r   )r   r   r   r   )r   r   )r   r   r   r   )r   r   r   r"   )
__doc__
__future__r   r
   r   r   r   r!   r?   rC   r   r   r   <module>rF      s      # " " " " " 				    5 5 5 5
   R R R R
       F! ! ! ! ! !r   