o
    Wi                     @  s$  d dl mZ d dlZd dl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 eeZdZdZdZdZd5ddZ	d6d7ddZd8d d!Z	"	"	d9d:d'd(Z 	"	"	"	d;d<d-d.Z!d=d/d0Z"d>d1d2Z#d?d3d4Z$dS )@    )annotationsN)git)output)InvalidConfigError)load_config)	all_hooks)install_hook_envs)Store)make_executable)resource_text)s    4d9958c90bc262f47553e2c073f14cfes    d8ee923c46731b42cd95cc869add4062s    49fd668cb42069aa1b6048464be5d395s    79f09a650522a87b0da915d0d983b2des    e358c9dae00eac5d06b38dfdb1e33a8cs    138fd403232d2ddd5efb44317e38bf03z# start templated
z# end templated
cfg_filenamestr
hook_typeslist[str] | Nonereturn	list[str]c                 C  s8   |d ur|S z	t | }W |d S  ty   dg Y S w )Nz
pre-commitdefault_install_hook_types)r   r   )r   r   cfg r   Y/home/ubuntu/.local/lib/python3.10/site-packages/pre_commit/commands/install_uninstall.py_hook_types#   s   

r   	hook_typegit_dir
str | Nonetuple[str, str]c                 C  s2   |d ur|nt  }tj|d| }|| dfS )Nhooksz.legacy)r   get_git_common_dirospathjoin)r   r   pthr   r   r   _hook_paths/   s   r!   filenameboolc                   s^   t j| sdS t| d}|  W d    n1 sw   Y  t fddtft D S )NFrbc                 3  s    | ]}| v V  qd S Nr   ).0hcontentsr   r   	<genexpr>=   s    z is_our_script.<locals>.<genexpr>)r   r   existsopenreadanyCURRENT_HASHPRIOR_HASHES)r"   fr   r(   r   is_our_script8   s   
r2   Fconfig_file	overwriteskip_on_missing_configNonec                 C  st  t ||d\}}tjtj|dd tj|r#t|s#t|| |r1tj	|r1t
| ntj	|r@td| d dd|  d| g}|rR|d	 t|d
M}td}	|	t\}
}|t\}}tjdkrt|d ||
t  |dttj d t|}|d| d |t|  W d    n1 sw   Y  t| td|  d S )N)r   T)exist_okz1Running in migration mode with existing hooks at z
Use -f to use only pre-commit.z	hook-implz	--config=z--hook-type=z--skip-on-missing-configwz	hook-tmplwin32z
#!/bin/sh
zINSTALL_PYTHON=
zARGS=(z)
zpre-commit installed at )r!   r   makedirsr   dirnamelexistsr2   shutilmover+   remover   
write_lineappendr,   r   splitTEMPLATE_STARTTEMPLATE_ENDsysplatformwriteshlexquote
executabler   r
   )r3   r   r4   r5   r   	hook_pathlegacy_pathargs	hook_filer)   beforerest_afterargs_sr   r   r   _install_hook_script@   s6   




rU   storer	   r   intc                 C  sR   |d u rt  rtd dS t| |D ]}t| ||||d q|r't| | dS )NzkCowardly refusing to install hooks with `core.hooksPath` set.
hint: `git config --unset-all core.hooksPath`   )r4   r5   r   r   )r   has_core_hookpaths_setloggererrorr   rU   install_hooks)r3   rV   r   r4   r   r5   r   r   r   r   r   installr   s   	
r]   c                 C  s   t tt| || dS Nr   )r   r   r   )r3   rV   r   r   r   r\      s   r\   c                 C  sn   t | \}}tj|rt|sd S t| t|  d tj|r5t|| td|  d S d S )Nz uninstalledzRestored previous hooks to )	r!   r   r   r+   r2   r@   r   rA   replace)r   rL   rM   r   r   r   _uninstall_hook_script   s   
r`   c                 C  s   t | |D ]}t| qdS r^   )r   r`   )r3   r   r   r   r   r   	uninstall   s   
ra   )r   r   r   r   r   r   r%   )r   r   r   r   r   r   )r"   r   r   r#   )FFN)r3   r   r   r   r4   r#   r5   r#   r   r   r   r6   )FFFN)r3   r   rV   r	   r   r   r4   r#   r   r#   r5   r#   r   r   r   rW   )r3   r   rV   r	   r   rW   )r   r   r   r6   )r3   r   r   r   r   rW   )%
__future__r   loggingos.pathr   rI   r>   rF   
pre_commitr   r   pre_commit.clientlibr   r   pre_commit.repositoryr   r   pre_commit.storer	   pre_commit.utilr
   r   	getLogger__name__rZ   r0   r/   rD   rE   r   r!   r2   rU   r]   r\   r`   ra   r   r   r   r   <module>   sH    


	6

