0i!ddlmZddlZddlZddlZddlZddlZddlm Z ddlm Z ddlm Z ddl m ZddlmZddlmZddlmZdd lmZdd lmZdd lmZdd lmZej0d ZddZdZddZGddZy)) annotationsN)Callable) Generator)Sequence) clientlib) file_lock)git)CalledProcessError)clean_path_on_failure cmd_output_b) resource_text pre_commitc>tjjdxs^tjj tjjdxstjj dd}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_HOMEXDG_CACHE_HOMEz~/.cachez pre-commit)osenvirongetpathjoin expanduserrealpath)rets ?/opt/hc_python/lib/python3.12/site-packages/pre_commit/store.py_get_default_directoryrsj **..* + rww|| '(JBGG,>,>z,J0C 77  C  )z Cargo.tomlzmain.gozgo.modzmain.rsz .npmignorez package.jsonz!pre-commit-package-dev-1.rockspecz&pre_commit_placeholder_package.gemspeczsetup.pyzenvironment.ymlz Makefile.PLz pubspec.yamlz renv.lockzrenv/activate.Rzrenv/LICENSE.renvctD]}tjj|\}}t d|}tjj ||}tjj ||}tj |dt|d5}|j|dddy#1swYxYw)Nempty_template_Texist_okw) _LOCAL_RESOURCESrrsplitrrmakedirsopenwrite) directoryresourceresource_dirnameresource_basenamecontents target_dir target_filefs r_make_local_repor00s$.0ggmmH.E++ ?3D2E!FGWW\\)-=> ggll:/@A  J. +s #q GGH $ # % $ #s B::C ceZdZeeZd ddZejddZ ej d ddZ e ddZ ddZ ddZddZddd Zdd Zdd Zdd Zy)StoreNc|xstj|_tjj |jd|_tjj|jxr/tj|jtj |_ tjj|jsotj|jdttjj |jdd5}|jddddtjj|j ry|j5tjj|j r dddytj |j\}}tj"||j%|5}|j'd |j)|dddtj*||j dddy#1swYxYw#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));)r2get_default_directoryr(rrrr6existsaccessW_OKreadonlyr%r&r'exclusive_locktempfilemkstempcloseconnect executescript_create_configs_tablereplace)selfr(r/fdtmpfiledbs r__init__zStore.__init__>s"Ce&A&A&Cww||DNNG< GGNN4>> * 3 $.."''2 2 ww~~dnn- KK 6bggll4>>8>$,, '   "ww~~dll+# " #**t~~>KB HHRLg."  **2./ JJw -+# "CB"/.# "s7*I>+I)2A I)<#I(I)II& "I))I2c#Kdd}tjtjj |j d|5ddddy#1swYyxYww)Nc.tjdy)NzLocking pre-commit directory)loggerinforr blocked_cbz(Store.exclusive_lock..blocked_cbis KK6 7rz.lock)returnNone)rlockrrrr()rDrNs rr<zStore.exclusive_lockgs= 8^^BGGLLA: N O N NsAAA AAAc#K|xs |j}tjtj|5}|5|ddddddy#1swYxYw#1swYyxYwwN)r6 contextlibclosingsqlite3r@)rDr6rGs rr@z Store.connectosT )T\\   8 9R: 9: 9s39A,A AA  A,A A  A)%A,c6|r|ddj|S|S)N:,)r)clsrepodepss r db_repo_namezStore.db_repo_name}s$ V1SXXd^,- -Krc2}j|dfd }|}|r|Sj5|}|r |cdddStjddt j dj }t|5||dddj5} | jd|gdddtj||ddd|S#1swYWxYw#1swY5xYw#1swYSxYw)Ncj5}|jdfj}|r|dndcdddS#1swYyxYw)Nz1SELECT path FROM repos WHERE repo = ? AND ref = ?r)r@executefetchone)rGresultrefr[rDs r _get_resultz$Store._new_repo.._get_resultsI2G3K(*%+vay  s +AAzInitializing environment for .r[)prefixr5z4INSERT INTO repos (repo, ref, path) VALUES (?, ?, ?))rO str | None) r]r<rKrLr=mkdtempr(r r@r`rwarn_for_stages_on_repo_init) rDr[rcr\ make_strategy original_repordrbr(rGs ``` r _new_repozStore._new_repos   t, 5 M  " ]F # " KK7vQ? @ ((DNNKI&y1i(22 J3 *  2 2=) L'#*21 #*sB D AD  C4D 6D D 4C= 9D D D  Dc@|ddd|d||ddddy ) z.clone_strategy.._git_cmdsUBTBycBr)rstrrOrP)r init_repo no_git_envrzr rv)r(rrrcr[rDs` @rclone_strategyz#Store.clone..clone_strategysW MM)T *.."C C 4##C2% 4$$S(3 4sA A'&A'r(rrOrP)rl)rDr[rcr\rs``` rclonez Store.clones 4~~dC~>>rcN|jdtj|tS)Nlocal)rlCLOCAL_REPO_VERSIONr0)rDr\s r make_localzStore.make_locals#~~ Q))41A  rc&|jdy)NzQCREATE TABLE IF NOT EXISTS configs ( path TEXT NOT NULL, PRIMARY KEY (path));)rA)rDrGs rrBzStore._create_configs_tables   rc.|jrytjj|}tjj |sy|j 5}|j ||jd|fdddy#1swYyxYw)Nz(INSERT OR IGNORE INTO configs VALUES (?))r;rrrr8r@rBr`)rDrrGs rmark_config_usedzStore.mark_config_usedsg == ww%ww~~d#  \\^r  & &r * JJAD7 K^^s %B  BrS)r(rgrOrP)rOzGenerator[None])r6rgrOzGenerator[sqlite3.Connection])r[rr\ Sequence[str]rOr) r[rrcrr\rrjzCallable[[str], None]rOr)rcrruzCallable[..., None]rOrP)rM)r[rrcrr\rrOr)r\rrOr)rGzsqlite3.ConnectionrOrP)rrrOrP)__name__ __module__ __qualname__ staticmethodrr7rHrTcontextmanagerr<r@ classmethodr]rlrvrzrrrBrrMrrr2r2;s()?@'.R#'   '   +++ + 1 + +Z@  ?"   Lrr2)rOrr) __future__rrTloggingos.pathrrVr=collections.abcrrrpre_commit.constants constantsrrrrr pre_commit.utilr r r r getLoggerrKrr#r0r2rMrrrsl"$%$ .1()   < ( !pLpLr