
    wi                    ,   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j        e          ZdZdZdZdZd-dZ	 d.d/dZd0dZ	 	 	 d1d2d$Z 	 	 	 	 d3d4d)Z!d5d*Z"d6d+Z#d7d,Z$dS )8    )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                `    ||S 	 t          |           }|d         S # t          $ r dgcY S w xY w)Ndefault_install_hook_typesz
pre-commit)r   r   )r   r   cfgs      u/root/.openclaw/workspace/chatterbox_venv_py311/lib/python3.11/site-packages/pre_commit/commands/install_uninstall.py_hook_typesr   #   sY    	5l++C 344 " 	" 	" 	" >!!!	"s    --	hook_typegit_dir
str | Nonetuple[str, str]c                    ||nt          j                    }t          j                            |d|           }|| dfS )Nhooksz.legacy)r   get_git_common_dirospathjoin)r   r   pths      r   _hook_pathsr#   /   sC     !,gg#2H2J2JG
',,w
3
3C3    filenameboolc                   t           j                            |           sdS t          | d          5 }|                                d d d            n# 1 swxY w Y   t          fdt          ft          z   D                       S )NFrbc              3      K   | ]}|v V  	d S N ).0hcontentss     r   	<genexpr>z is_our_script.<locals>.<genexpr>=   s'      EEqH}EEEEEEr$   )r   r    existsopenreadanyCURRENT_HASHPRIOR_HASHES)r%   fr.   s     @r   is_our_scriptr7   8   s    7>>(## u	h		 6688              EEEE|o&DEEEEEEs   AAAFconfig_file	overwriteskip_on_missing_configNonec                   t          ||          \  }}t          j        t          j                            |          d           t          j                            |          r$t          |          st          j        ||           |r4t          j        	                    |          rt          j
        |           n7t          j        	                    |          rt          j        d| d           dd|  d| g}|r|                    d	           t          |d
          5 }t          d          }	|	                    t"                    \  }
}|                    t$                    \  }}t&          j        dk    r|                    d           |                    |
t"          z              |                    dt-          j        t&          j                   d           t-          j        |          }|                    d| d           |                    t$          |z              d d d            n# 1 swxY w Y   t5          |           t          j        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lexistsr7   shutilmover0   remover   
write_lineappendr1   r   splitTEMPLATE_STARTTEMPLATE_ENDsysplatformwriteshlexquote
executabler!   r   )r8   r   r9   r:   r   	hook_pathlegacy_pathargs	hook_filer.   beforerest_afterargs_ss                  r   _install_hook_scriptr[   @   s    )GDDDI{K	**T:::: 
wy!! ,-	*B*B ,I{+++  
RW^^K00 

	+		$	$ 
. . . .	
 	
 	

 2[224N94N4NOD 0.///	i		 . --~~n55::l++5 <7""OOM***/000I%+cn*E*EIIIJJJD!!,,,,---u,---!. . . . . . . . . . . . . . ." I
<<<=====s   *DIIIstorer
   r   intc                    |/t          j                    rt                              d           dS t	          | |          D ]}t          | ||||           |rt          | |           dS )NzkCowardly refusing to install hooks with `core.hooksPath` set.
hint: `git config --unset-all core.hooksPath`   )r9   r:   r   r   )r   has_core_hookpaths_setloggererrorr   r[   install_hooks)r8   r\   r   r9   r   r:   r   r   s           r   installrd   r   s     3577<	
 	
 	
 q j99 
 
	#9		
 	
 	
 	
 	
  *k5)))1r$   c                \    t          t          t          |           |          |           dS Nr   )r	   r   r   )r8   r\   s     r   rc   rc      s)    iK 8 8%@@%HHH1r$   c                z   t          |           \  }}t          j                            |          rt	          |          sd S t          j        |           t          j        |  d           t          j                            |          r.t          j        ||           t          j        d|            d S d S )Nz uninstalledzRestored previous hooks to )	r#   r   r    r0   r7   rF   r   rG   replace)r   rR   rS   s      r   _uninstall_hook_scriptri      s    (33I{ 7>>)$$ M),D,D Ii
000111	w~~k"" E

;	***C	CCDDDDDE Er$   c                J    t          | |          D ]}t          |           dS rf   )r   ri   )r8   r   r   s      r   	uninstallrk      s1     j99 * *	y))))1r$   )r   r   r   r   r   r   r*   )r   r   r   r   r   r   )r%   r   r   r&   )FFN)r8   r   r   r   r9   r&   r:   r&   r   r   r   r;   )FFFN)r8   r   r\   r
   r   r   r9   r&   r   r&   r:   r&   r   r   r   r]   )r8   r   r\   r
   r   r]   )r   r   r   r;   )r8   r   r   r   r   r]   )%
__future__r   loggingos.pathr   rO   rD   rL   
pre_commitr   r   pre_commit.clientlibr   r   pre_commit.repositoryr   r	   pre_commit.storer
   pre_commit.utilr   r   	getLogger__name__ra   r5   r4   rJ   rK   r   r#   r7   r[   rd   rc   ri   rk   r+   r$   r   <module>rv      s   " " " " " "     



             3 3 3 3 3 3 , , , , , , + + + + + + 3 3 3 3 3 3 " " " " " " + + + + + + ) ) ) ) ) ) 
	8	$	$ 3&"	5 	5 	5 	5 #         F F F F  ',"/> /> /> /> />l  ',"    <   
E E E E     r$   