+
    4jy6                       R t ^ RIHt ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RI	t	^ RI
Ht ^ RIHt ^ RIHt ^RIHt . R&Ot]P&                  ! ]4      t]P,                  ! R
4      t]P,                  ! R4      tRt^xtRtR't ! R R]4      t]! RRR7       ! R R4      4       t]! RRR7       ! R R	4      4       t R R lt!R R lt"R R lt#RR/R R llt$R R lt%RR/R  R! llt&R" R# lt'R$ R% lt(R# )(ad  Shallow VCS clone helper for nab-index.

Performs ``git clone --depth 1`` against a directory under the cache
root.  URL admission lives upstream in
:func:`nab_python._vcs_admission.admit_vcs_url`.

Cache layout under ``cache_root / "vcs"``:

    <repo-key>/<commit-sha>/

``repo-key`` is the 16-char prefix of a SHA-256 over the canonicalised
repo URL (``vcs+`` prefix stripped).  ``commit-sha`` is always a
concrete 40-char hash; floating refs are resolved via
``git ls-remote`` before the clone runs.  A finished clone carries a
``.git/nab-complete`` marker file; a tree without it is discarded and
recloned.
)annotationsN)	dataclass)Path)urlsplit)subdirectory_escapesVcsCloneVcsCloneError
VcsRequestz^[0-9a-fA-F]{40}$z^git\+znab-completei  c                      ] tR t^PtRtRtR# )r   z,Raised when a clone or ref resolution fails. N)__name__
__module____qualname____firstlineno____doc____static_attributes__r       _/home/user/pdf2html-billing-ledger-validate/.venv/lib/python3.14/site-packages/nab_index/vcs.pyr   r   P   s    6r   T)frozenslotsc                  >    ] tR t^Tt$ RtR]R&   R]R&   RtR]R&   RtR	# )
r   a=  Result of :func:`prepare_clone`.

``path`` is the absolute filesystem path to the (possibly
cached) checked-out source tree.  ``commit_sha`` is the
40-char hex SHA the clone is pinned to.  ``subdirectory`` is the
relative path inside the checkout that contains the project
pyproject.toml; ``""`` means the repo root.
r   pathstr
commit_sha subdirectoryr   N)r   r   r   r   r   __annotations__r   r   r   r   r   r   r   T   s     JOL#r   c                  Z    ] tR t^dt$ RtR]R&   R]R&   R]R&   R]R&   ]R R l4       tR	tR
# )r	   a4  Parsed representation of a ``git+https://repo.git@ref#...`` URL.

``ref`` may be a 40-char SHA or a branch / tag name.  ``ref`` of
``""`` means "HEAD"; the caller is expected to have decided
whether floating refs are permitted.  ``subdirectory`` is parsed
from the ``#subdirectory=...`` fragment if present.
r   schemerepo_urlrefr   c                    V ^8  d   QhRRRR/# )   urlr   returnr	   r   )formats   "r   __annotate__VcsRequest.__annotate__t   s     T T T
 Tr   c                   VP                  R4      w  r#p\        P                  V4      pVf   RV: 2p\        V4      hV\	        VP                  ^ 4      4      R p\        V4      w  rRp
VP                  R4       F"  pVP                  R4      w  rpVR8X  g   K   Tp
K$  	  \        V
4      '       d   RV
: R	V: 2p\        V4      hV ! R
WV
R7      # )z.Parse a pip-style VCS URL into its components.#Nznot a recognised VCS URL: r   &=r   zunsafe VCS subdirectory z in git)r   r   r    r   )		partition_VCS_PREFIX_REmatchr   lengroup_split_repo_refsplitr   )clsr#   url_no_frag_fragmentr/   msginnerrepor    r   fragment_partkeyvalues   &&            r   parseVcsRequest.parses   s     $'==#5 $$[1=.sg6C$$CA/12#E*	%^^C0M)33C8MCEn$$ 1  --,\,<DHC$$%$lSSr   r   N)	r   r   r   r   r   r   classmethodr>   r   r   r   r   r	   r	   d   s2     KM	HT Tr   c                    V ^8  d   QhRRRR/# )r"   r9   r   r$   ztuple[str, str]r   )r%   s   "r   r&   r&      s     : :3 :? :r   c                T   RV 9  dH   RV 9  d   V R3# V P                  R4      w  rpRV9   d   VP                  R4      w  rBpV RV 2V3# V R3# V P                  R4      w  rbpVP                  R4      w  rpV	'       d   RV9  d   V R3# VP                  R4      w  rBpV RV RV 2V3# )a  Split ``inner`` (no ``vcs+`` prefix, no fragment) into ``(repo, ref)``.

For URL forms (``scheme://...``), the ref is everything after the
last ``@`` that appears in the path component (after the netloc),
so branch names containing ``/`` (e.g. ``release/1.0``) survive.
A ``user@`` in the authority section is left alone.

For the SSH shortcut form (``user@host:path[@<ref>]``), the first
``:`` separates the auth+host from the path; an optional
``@<ref>`` may follow the path.
z://:r   @/)r-   
rpartition)
r9   	host_partr6   	path_part	path_repor    scheme_partrestnetlocslashs
   &         r   r2   r2      s     Ee2;"'//#"6	i) ) 4 4S 9I# k9+.44r{ ??51KD#~~c2F9Cy(r{!,,S1I#m3vha	{3S99r   c                    V ^8  d   QhRRRR/# )r"   r   r   r$   r   )r%   s   "r   r&   r&      s     E E E Er   c                v    \         P                  ! V P                  R 4      4      P                  4       R,          # )zutf-8:N   N)hashlibsha256encode	hexdigestr   s   &r   	_repo_keyrV      s(    >>(//'23==?DDr   c                    V ^8  d   QhRRRR/# )r"   r   r   r$   boolr   )r%   s   "r   r&   r&      s     / /S /T /r   c                2    \        V 4      P                  R8H  # )a  Return True when ``repo_url`` reaches its repo through the filesystem.

Offline means nab issues no network request of its own.  A ``file``
URL is read by path, so it stays available offline whatever the
authority says: git drops the authority outright on POSIX, and on
Windows turns it into a UNC path, which is a filesystem call like
any other.  Whether that path is backed by a local disk, NFS, or SMB
is the operating system's business, the same as it is for a
``file:`` index.
file)r   r   rU   s   &r   _is_local_repor[      s     H$$..r   offlineFc          
     ,    V ^8  d   QhRRRRRRRRRR	/# )
r"   
cache_rootr   requestr	   require_pinrX   r\   r$   r   r   )r%   s   "r   r&   r&      sA     C CCC 	C
 C Cr   c                  V'       * ;'       g    \        VP                  4      p\        WVR7      pV R,          \        VP                  4      ,          V,          p\	        V4      '       d   \        VVVP                  R7      # V'       g   RVP                   RV R2p\        V4      hVP                  P                  RRR7       VP                  4       '       d(   \	        V4      '       g   \        P                  ! V4       \        \        P                  ! VP                  V R	2R
R7      4      p\!        VP                  WX4        VP#                  V4       \        VVVP                  R7      #   \$         dU   p	\        P                  ! TRR7       \	        T4      '       g"   RTP                   RT RT	 2p\        T4      T	h Rp	?	LrRp	?	ii ; i)a^  Resolve ``request.ref`` to a SHA and ensure a clone exists at it.

When ``require_pin`` is True and the ref is not already a 40-char
SHA, raises :class:`VcsCloneError` rather than fetching a floating
ref.  When False, the helper consults ``git ls-remote`` to resolve
the named ref to a SHA, then performs a shallow clone of that
commit.

``offline`` withholds every git call that would reach the remote: a
complete cached clone is still served; anything else raises
:class:`VcsCloneError`.  A ``file://`` repo is read through the
filesystem rather than the network, so it still clones.

Idempotent: a destination carrying the completion marker is reused
without a fetch.  A fresh clone lands in a temporary sibling
directory and is renamed into place only once fully checked out, so
a concurrent or interrupted run never leaves a partial tree at the
cache path.
)r`   may_reach_remotevcs)r   r   r   zno cached clone of  @ z (offline mode)Tparentsexist_ok.z.tmp)dirprefixsuffixignore_errors	clone of z  could not be moved into place: N)r[   r   _resolve_sharV   _clone_completer   r   r   parentmkdirexistsshutilrmtreer   tempfilemkdtemp_shallow_clonerenameOSError)
r^   r_   r`   r\   rb   shadestr8   tmpexcs
   &&$$      r   prepare_cloner      s   4 #{FFnW5E5E&F
;KC 	'*:*: ;;cADt --
 	
 #G$4$4#5S_MC  KKdT2{{}}_T22 	d
xDKK3%q	&Q
RC7##S.
.

4 ))   .c.t$$G,,-S 6&&)U,   $#- %.s   E4 4G?A
GGc                    V ^8  d   QhRRRR/# )r"   r|   r   r$   rX   r   )r%   s   "r   r&   r&      s     8 8$ 84 8r   c                F    V R,          \         ,          P                  4       # )zFReturn True when ``dest`` holds a fully fetched and checked-out clone..git)_COMPLETE_MARKERis_file)r|   s   &r   rp   rp      s    6M,,5577r   rb   c               (    V ^8  d   QhRRRRRRRR/# )r"   r_   r	   r`   rX   rb   r$   r   r   )r%   s   "r   r&   r&     s8     E EE E 	E
 	Er   c          	        V P                   '       d2   \        P                  V P                   4      '       d   V P                   # V'       d+   RV P                   : RV P                  : R2p\	        V4      hV P                   ;'       g    RpV'       g    RV: RV P                   R2p\	        V4      hRR	V P                  WD R
2.p \
        P                  ! VRRR\        4       \        R7      pTP                  P                  4       P                  4       pT'       g   RT: RT P                   2p\	        T4      h\        R T 4       R4      p	T	e   T	MT^ ,          p
T
P!                  4       ^ ,          p\        P                  T4      '       g   RT
: 2p\	        T4      hT#   \        \
        P                  \
        P                  3 d'   pRT P                   RT RT 2p\	        T4      ThRp?ii ; i)zReturn a 40-char SHA for ``request.ref``.

Raises when ``require_pin`` is True and ``ref`` is not already a
SHA.  Otherwise consults ``git ls-remote`` to look up the ref, which
``may_reach_remote=False`` refuses: no cache holds a ref-to-SHA
mapping.
z!refusing to resolve floating ref z for z: vcs.require-pin is trueHEADzcannot resolve ref z at z9 (offline mode): only a pinned commit resolves from cacher,   z	ls-remote^{}T)checkcapture_outputtextenvtimeoutzgit ls-remote  : Nzno ref z
 found at c              3     "   T F4  qP                  4       R,          P                  R4      '       g   K0  Vx  K6  	  R# 5i)   r   N)r3   endswith).0lns   & r   	<genexpr>_resolve_sha.<locals>.<genexpr>@  s'     H"B)@)@)G22s   ->
>zunexpected ls-remote output: )r    FULL_GIT_SHA_REr/   r   r   
subprocessrun_git_env_LS_REMOTE_TIMEOUT_SECONDSFileNotFoundErrorCalledProcessErrorTimeoutExpiredstdoutstrip
splitlinesnextr3   )r_   r`   rb   r8   targetls_remote_argsprocr~   linespeeledchosenr{   s   &$$         r   ro   ro     s    {{{,,W[[99{{/ ?  ##<> 	 C  [[""FF!&40@0@/AGI 	 C  
 ['*:*:FheDTUN*~~
.
  KK**,EzG,<,<+=>C   HH$OF)VuQxF
,,.
C  %%-fZ8C  J1 	%%!! *
 w//0&C5AC c)*s   (F$ $*G4!G//G4c               (    V ^8  d   QhRRRRRRRR/# )r"   r   r   r{   r|   r   r$   Noner   )r%   s   "r   r&   r&   K  s(     6* 6*S 6*s 6*$ 6*4 6*r   c                   VP                  RRR7       \        4       p. ROpRRRRRW.p. ROp \        P                  ! VRVVR7       \        P                  ! VRVV\        R	7       \        P                  ! VRVVR7        TR,          \        ,          P                  4        R#   \
        \        P                  \        P                  3 d5   p\        P                  ! TRR
7       RT  RT RT 2p\        T4      ThRp?ii ; i  \         d5   p\        P                  ! TRR
7       RT  RT RT 2p\        T4      ThRp?ii ; i)a  Shallow-clone ``repo_url`` at exactly ``sha`` to ``dest``.

Uses ``git init`` + ``git fetch --depth 1`` to land precisely the
chosen commit without pulling history.  Hosts that disallow
direct sha fetch surface as a :class:`VcsCloneError` from the
fetch step.  The completion marker is written last, so its
presence proves the checkout finished.

``dest`` is the temporary directory ``prepare_clone`` created with
:func:`tempfile.mkdtemp`, so it already exists.
Tre   r,   --quietfetchz--depth1)r   cwdr   )r   r   r   r   rl   zfailed to clone rd   r   Nr   rn   z could not be marked complete: )r,   initr   )r,   checkoutr   
FETCH_HEAD)rr   r   r   r   _FETCH_TIMEOUT_SECONDSr   r   r   rt   ru   r   r   touchrz   )	r   r{   r|   r   	init_args
fetch_argscheckout_argsr~   r8   s	   &&&      r   rx   rx   K  sI    	JJtdJ+
*C*I)YXKJ@M*		
 	*	
 			
 *	)	)002 	%%!! * 	d$/ 
#cU"SE:C c)*  *d$/(3se+J3%PC c)*s0   AB' "D '*D/D  DE/EEc                   V ^8  d   QhRR/# )r"   r$   zdict[str, str]r   )r%   s   "r   r&   r&     s      . r   c                     \        \        P                  4      p \         F  pV P	                  VR4       K  	  RV R&   V P                  RR4       V P                  RR4       V # )a  Return an environment for git subprocesses.

Disables interactive prompts and any auto-detected user config so
the clone fails fast on unauthenticated repos rather than hanging,
and drops the inherited repo-selection variables so every call acts
on the directory nab passes as ``cwd``.
N0GIT_TERMINAL_PROMPTGIT_CONFIG_GLOBALz	/dev/nullGIT_CONFIG_SYSTEM)dictosenviron_REPO_SELECTION_VARSpop
setdefault)r   names     r   r   r     sZ     rzz
C$d % "%CNN&4NN&4Jr   )r   r   r   r	   r   )GIT_DIRGIT_WORK_TREEGIT_INDEX_FILEGIT_OBJECT_DIRECTORY GIT_ALTERNATE_OBJECT_DIRECTORIESGIT_COMMON_DIRGIT_NAMESPACE))r   
__future__r   rQ   loggingr   rert   r   rv   dataclassesr   pathlibr   urllib.parser   subdirr   __all__	getLoggerr   loggercompiler   r.   r   r   r   r   	Exceptionr   r   r	   r2   rV   r[   r   rp   ro   rx   r   r   r   r   <module>r      s  $ #   	 	    !  ! ( 
		8	$ **12I& "  !   
 7I 7 $d#  $ $d#!T !T $!TH::E/C
 CL8
E "	EP6*rr   