관리-도구
편집 파일: install_uninstall.cpython-38.pyc
U ,�e� � @ s` d dl mZ d dlZd dlZd dlZd dlZd dlZd dlm Z d dlm Z d dlmZ d dlm Z d dlmZ d dlmZ d d lmZ d d lmZ d dlmZ e�e�ZdZd ZdZdZdddd�dd�Zd2dddd�dd�Zddd�dd�Zd3dddddd d!�d"d#�Z d4dd$dddddd%d&�d'd(�Z!dd$d%d)�d*d+�Z"dd d,�d-d.�Z#ddd%d/�d0d1�Z$dS )5� )�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 �strzlist[str] | Nonez list[str])�cfg_filename� hook_types�returnc C s@ |d k r|S zt | �}W n tk r2 dg Y S X |d S d S )Nz pre-commitZdefault_install_hook_types)r r )r r �cfg� r �S/opt/hc_python/lib/python3.8/site-packages/pre_commit/commands/install_uninstall.py�_hook_types# s r z str | Noneztuple[str, str])� hook_type�git_dirr c C s2 |d k r|nt �� }tj�|d| �}||� d�fS )N�hooksz.legacy)r Zget_git_common_dir�os�path�join)r r �pthr r r �_hook_paths/ s r �bool)�filenamer c sJ t j�| �sdS t| d��}|�� � W 5 Q R X t� fdd�tft D ��S )NF�rbc 3 s | ]}|� kV qd 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 r+ F�None)�config_filer � overwrite�skip_on_missing_configr r c C s` t ||d�\}}tjtj�|�dd� tj�|�rFt|�sFt�||� |rbtj� |�rbt� |� ntj� |�r�t�d|� d�� dd| � �d|� �g}|r�|� d � t|d ���}td�} | �t�\} }|�t�\}} tjdkr�|�d � |�| t � |�dt�tj�� d�� t�|�}|�d|� d�� |�t| � W 5 Q R X 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 zINSTALL_PYTHON=� zARGS=(z) zpre-commit installed at )r r �makedirsr �dirname�lexistsr+ �shutil�mover$ �remover � write_line�appendr% r �split�TEMPLATE_START�TEMPLATE_END�sys�platform�write�shlex�quote� executabler r )r- r r. r/ r � hook_path�legacy_path�argsZ hook_filer"