
    UAj                        S r SSKJr  SSKrSSKJr  SSKJr  SSKJ	r	  SSK
Jr  \" S5      rS	rS
rSS jrSS jrSS jr\4SS jjrSS jrg)zRead-only Git repository discovery.

For every repository found we collect only non-sensitive metadata. Remote URLs
are sanitized to strip any embedded credentials/tokens. We never read git
config secrets, stored credentials, or commit contents.
    )annotationsN)Path)Any)run_readonly)
get_loggerzdiscovery.git)z/var/wwwz/srvz/homez/opt   c                ^    U (       d  g[         R                  " SSU R                  5       5      $ )zStrip credentials from a remote URL.

https://user:token@github.com/x/y.git -> https://github.com/x/y.git
Leaves SSH-style remotes (git@host:repo) untouched, as they carry no secret.
Nz(https?://)[^/@]*@z\1)resubstrip)urls    7D:\Programs\laragon\www\wolf\agent\src\discovery\git.pysanitize_remoter      s$     66'		<<    c                f    [        SS[        U 5      /UQ5      nU(       a  UR                  5       $ S $ )Ngitz-C)r   strr   )repoargsoutputs      r   _gitr   $   s/    5$D	9D9:F#6<<>--r   c           	         U R                   n[        U/ SQ5      n[        USS/5      n[        U5      [        U5      [        U/ SQ5      [        U/ SQ5      [        U/ SQ5      [	        U5      S.$ )z:Collect the allow-listed metadata for a single repository.)configz--getzremote.origin.urlstatusz--porcelain)z	rev-parsez--abbrev-refHEAD)log-1z--format=%H)r   r   z--format=%cI)path
remote_urlcurrent_branchlast_commit_hashlast_commit_datedirty_state)parentr   r   r   bool)repo_dirr   remoter   s       r   inspect_repor(   )   sj    ??D$@AF$=12FD	%f-t%JK 'CD 'DEF| r   c                   / n[        5       nU  H  n[        U5      nUR                  5       (       d  M%  [        US[        5       HK  n[        UR                  5      nXb;   a  M  UR                  U5         UR                  [        U5      5        MM     M     U$ ! [         a!  n[        R                  SXW5         SnAM{  SnAff = f)z;Find .git directories under the scan roots (bounded depth).z.gitzfailed to inspect %s: %sN)setr   is_dir_bounded_glob
_MAX_DEPTHr   r$   addappendr(   OSErrorr   debug)rootsreposseenrootbasegit_dirkeyexcs           r   find_repositoriesr:   8   s    "$EUDDz{{}}$T6:>Ggnn%C{HHSMD\'23 ?	  L  D		4gCCDs   6B
C$C  Cc              #     #    [        US-   5       H?  nU(       a  SR                  S/U-  U/-   5      OUn U R                  U5       Sh  vN   MA     g N	! [         a     MS  f = f7f)z;Yield paths named `name` up to max_depth levels below base.   /*N)rangejoinglobr0   )r6   name	max_depthdepthpatterns        r   r,   r,   L   sd     y1}%6;#((C55=D612	yy))) & * 		s:   4A(AAAA(A
A%!A($A%%A()r   
str | NonereturnrF   )r   r   r   z	list[str]rG   rF   )r&   r   rG   zdict[str, Any])r2   ztuple[str, ...]rG   zlist[dict[str, Any]])r6   r   rB   r   rC   int)__doc__
__future__r   r
   pathlibr   typingr   discovery.systemr   loggerr   r   _SCAN_ROOTSr-   r   r   r(   r:   r,    r   r   <module>rQ      sR    # 	   ) ! 4
	=.
 0; (r   