U
    nËj  ã                   @  sR   d Z ddlmZ ddlZddlZdddœdd„Zdd	œd
d„Zdddœdd„ZdS )zjGit utilities, adopted from mypy's git utilities (https://github.com/python/mypy/blob/master/mypy/git.py).é    )ÚannotationsNÚstrÚbool)ÚdirÚreturnc                 C  s   t j t j | d¡¡S )z3Is the given directory version-controlled with git?z.git)ÚosÚpathÚexistsÚjoin©r   © r   ú;/tmp/pip-unpacked-wheel-zvl9l234/pydantic/_internal/_git.pyÚis_git_repo	   s    r   )r   c                   C  sF   zt  ddg¡ W dS  t jk
r,   Y dS  tk
r@   Y dS X dS )zCan we run the git executable?Úgitz--helpTFN)Ú
subprocessÚcheck_outputÚCalledProcessErrorÚOSErrorr   r   r   r   Úhave_git   s    r   c                 C  s    t jddddg| d� d¡ ¡ S )z.Get the SHA-1 of the HEAD of a git repository.r   z	rev-parsez--shortÚHEAD)Úcwdzutf-8)r   r   ÚdecodeÚstripr   r   r   r   Úgit_revision   s    r   )Ú__doc__Ú
__future__r   r   r   r   r   r   r   r   r   r   Ú<module>   s   