Viewing File: /opt/hc_python/lib/python3.12/site-packages/pre_commit/__pycache__/store.cpython-312.pyc

�

i0i!���ddlmZddlZddlZddlZddlZddlZddlm	Z	ddlm
Z
ddlmZddlm
ZddlmZddlmZddlmZdd	lmZdd
lmZddlmZddlmZej0d
�Zdd�ZdZdd�ZGd�d�Zy)�)�annotationsN)�Callable)�	Generator)�Sequence)�	clientlib)�	file_lock)�git)�CalledProcessError)�clean_path_on_failure��cmd_output_b)�
resource_text�
pre_commitc�>�tjjd�xs^tjj	tjjd�xstjjd�d�}tjj
|�S)a7Returns the default directory for the Store.  This is intentionally
    underscored to indicate that `Store.get_default_directory` is the intended
    way to get this information.  This is also done so
    `Store.get_default_directory` can be mocked in tests and
    `_get_default_directory` can be tested.
    �PRE_COMMIT_HOME�XDG_CACHE_HOMEz~/.cachez
pre-commit)�os�environ�get�path�join�
expanduser�realpath)�rets �?/opt/hc_python/lib/python3.12/site-packages/pre_commit/store.py�_get_default_directoryrsj��
�*�*�.�.�*�
+��r�w�w�|�|�
�
�
���'�(�J�B�G�G�,>�,>�z�,J��0�C��7�7���C� � �)z
Cargo.tomlzmain.gozgo.modzmain.rsz
.npmignorezpackage.jsonz!pre-commit-package-dev-1.rockspecz&pre_commit_placeholder_package.gemspeczsetup.pyzenvironment.ymlzMakefile.PLzpubspec.yamlz	renv.lockzrenv/activate.Rzrenv/LICENSE.renvc��tD]�}tjj|�\}}t	d|���}tjj||�}tjj||�}tj|d��t|d�5}|j|�ddd���y#1swY��xYw)N�empty_template_T��exist_ok�w)	�_LOCAL_RESOURCESrr�splitrr�makedirs�open�write)�	directory�resource�resource_dirname�resource_basename�contents�
target_dir�target_file�fs        r�_make_local_repor00s���$��.0�g�g�m�m�H�.E�+��+� �?�3D�2E�!F�G���W�W�\�\�)�-=�>�
��g�g�l�l�:�/@�A��
���J��.�
�+�s�
#�q�
�G�G�H��$�
#�
%�$�
#�s�B:�:C	c���eZdZee�Zd
dd�Zejdd��Z	ej	d
			dd��Z
edd��Z										dd�Z
dd�Zdd�Zddd	�Zdd
�Zdd�Zdd�Zy)�StoreNc���|xstj�|_tjj|jd�|_tjj|j�xr/tj|jtj�|_
tjj|j�sotj|jd��ttjj|jd�d�5}|jd�ddd�tjj|j�ry|j�5tjj|j�r
	ddd�ytj |j��\}}tj"|�|j%|��5}|j'd	�|j)|�ddd�tj*||j�ddd�y#1swY��xYw#1swY�?xYw#1swYyxYw)
Nzdb.dbTr �READMEr"zmThis directory is maintained by the pre-commit project.
Learn more: https://github.com/pre-commit/pre-commit
)�dir)�db_pathzuCREATE TABLE repos (    repo TEXT NOT NULL,    ref TEXT NOT NULL,    path TEXT NOT NULL,    PRIMARY KEY (repo, ref));)r2�get_default_directoryr(rrrr6�exists�access�W_OK�readonlyr%r&r'�exclusive_lock�tempfile�mkstemp�close�connect�
executescript�_create_configs_table�replace)�selfr(r/�fd�tmpfile�dbs      r�__init__zStore.__init__>s���"�C�e�&A�&A�&C����w�w�|�|�D�N�N�G�<����G�G�N�N�4�>�>�*�
3��	�	�$�.�.�"�'�'�2�2�	
�
�
�w�w�~�~�d�n�n�-��K�K�����6��b�g�g�l�l�4�>�>�8�<�c�B�a����M��C��7�7�>�>�$�,�,�'��
�
 �
 �
"��w�w�~�~�d�l�l�+��#�
"�#�*�*�t�~�~�>�K�B���H�H�R�L����g��.�"�� � ����*�*�2�.�/�
�J�J�w����-�+#�
"�C�B��"/�.��#�
"�s7�*I�>+I)�2A
I)�<#I�(I)�I�I&	�"I)�)I2c#��K�dd�}tjtjj	|j
d�|�5d��ddd�y#1swYyxYw�w)Nc�.�tjd�y)NzLocking pre-commit directory)�logger�info�rr�
blocked_cbz(Store.exclusive_lock.<locals>.blocked_cbis���K�K�6�7rz.lock)�return�None)r�lockrrrr()rDrNs  rr<zStore.exclusive_lockgs=����	8��^�^�B�G�G�L�L�����A�:�
N��O�
N�
N�s�AA�A�
	A�A�Ac#��K�|xs|j}tjtj|��5}|5|��ddd�ddd�y#1swY�xYw#1swYyxYw�w�N)r6�
contextlib�closing�sqlite3r@)rDr6rGs   rr@z
Store.connectosT����
�)�T�\�\���
�
����� 8�
9�R�����:�
9����:�
9�s3�9A,�A �A�A �	A,�A	�A � A)�%A,c�6�|r|�ddj|���S|S)N�:�,)r)�cls�repo�depss   r�db_repo_namezStore.db_repo_name}s$����V�1�S�X�X�d�^�,�-�-��Krc�2�����}�j�|��d���fd�}|�}|r|S�j�5|�}|r|cddd�Stjd��d��t	j
d�j��}t|�5||�ddd��j�5}	|	jd��|g�ddd�tj||�ddd�|S#1swY�WxYw#1swY�5xYw#1swYSxYw)Nc����j�5}|jd��f�j�}|r|dndcddd�S#1swYyxYw)Nz1SELECT path FROM repos WHERE repo = ? AND ref = ?r)r@�execute�fetchone)rG�result�refr[rDs  ���r�_get_resultz$Store._new_repo.<locals>._get_result�sI�������2����G��3�K���(�*��%+�v�a�y�� ���s�+A�AzInitializing environment for �.r[)�prefixr5z4INSERT INTO repos (repo, ref, path) VALUES (?, ?, ?))rO�
str | None)r]r<rKrLr=�mkdtempr(rr@r`r�warn_for_stages_on_repo_init)
rDr[rcr\�
make_strategy�
original_repordrbr(rGs
```       r�	_new_repozStore._new_repo�s�����
�� � ��t�,��	5������M�
�
 �
 �
"� �]�F���	#�
"�
�K�K�7��v�Q�?�@� �(�(��D�N�N�K�I�&�y�1��i�(�2�����2��
�
�J��3�	�*�� �
�2�2�=�)�L�'#�*��2�1�� ���#�*��sB�D�AD�	C4�D�6D�D�4C=	�9D�D		�D�Dc�@�|ddd�|d|�|dddd�y	)
z<Perform a complete clone of a repository and its submodules �fetch�originz--tags�checkout�	submodule�update�--init�--recursiveNrM)rDrc�git_cmds   r�_complete_clonezStore._complete_clone�s(��	���8�,��
�C� ���X�x��?rc	�P�d}|d|dd|d�|dd�|d|dd	d
dd�y)
z;Perform a shallow clone of a repository and its submodules zprotocol.version=2z-crnroz	--depth=1rp�
FETCH_HEADrqrrrsrtNrM)rDrcru�
git_configs    r�_shallow_clonezStore._shallow_clone�s=��*�
���j�'�8�S�+�F��
�L�)���*�k�8�X�}��	
rc�@����d���fd�}�j��||�S)z2Clone the given url and checkout the specific ref.c������tj���tj��d��fd�}	�j�|�y#t$r�j�|�YywxYw)Nc�&��tdg|����d��y)Nr	)�cwd�envr)�argsr(rs ��r�_git_cmdz5Store.clone.<locals>.clone_strategy.<locals>._git_cmd�s����U�B�T�B�y�c�Br)r��strrOrP)r	�	init_repo�
no_git_envrzr
rv)r(r�rrcr[rDs` @���r�clone_strategyz#Store.clone.<locals>.clone_strategy�sW����M�M�)�T�*��.�.�"�C�
C�
4��#�#�C��2��%�
4��$�$�S�(�3�
4�s�A	�	A'�&A'�r(r�rOrP)rl)rDr[rcr\r�s```  r�clonezStore.clone�s���
	4��~�~�d�C��~�>�>rc�N�|jdtj|t�S)N�local)rl�C�LOCAL_REPO_VERSIONr0)rDr\s  r�
make_localzStore.make_local�s#���~�~��Q�)�)�4�1A�
�	
rc�&�|jd�y)NzQCREATE TABLE IF NOT EXISTS configs (   path TEXT NOT NULL,   PRIMARY KEY (path));)rA)rDrGs  rrBzStore._create_configs_table�s��
���
�	
rc�.�|jrytjj|�}tjj	|�sy|j�5}|j
|�|jd|f�ddd�y#1swYyxYw)Nz(INSERT OR IGNORE INTO configs VALUES (?))r;rrrr8r@rBr`)rDrrGs   r�mark_config_usedzStore.mark_config_used�sg���=�=���w�w����%���w�w�~�~�d�#��
�\�\�^�r��&�&�r�*��J�J�A�D�7�K��^�^�s�%B�BrS)r(rgrOrP)rOzGenerator[None])r6rgrOzGenerator[sqlite3.Connection])r[r�r\�
Sequence[str]rOr�)
r[r�rcr�r\r�rjzCallable[[str], None]rOr�)rcr�ruzCallable[..., None]rOrP)rM)r[r�rcr�r\r�rOr�)r\r�rOr�)rGzsqlite3.ConnectionrOrP)rr�rOrP)�__name__�
__module__�__qualname__�staticmethodrr7rHrT�contextmanagerr<r@�classmethodr]rlrvrzr�r�rBr�rMrrr2r2;s���(�)?�@��'.�R���������#'����
'��������+��+��+� �	+�
1�+�

�
+�Z@�	
�?�"
�

�
Lrr2)rOr�r�)�
__future__rrT�logging�os.pathrrVr=�collections.abcrrr�pre_commit.constants�	constantsr�rrrr	�pre_commit.utilr
rr
r�	getLoggerrKrr#r0r2rMrr�<module>r�sl��"������$�%�$� � � ��.�1�(�)�
��	�	�<�	(��!����pL�pLr
Back to Directory File Manager