Ë
    Fêñi}  ã            
      óZ  — d dl mZ d dlmZ d dlmZ  G d„ d«      Zedk(  rŠd dlZ e«       Z	e	j                  rr ej                  «       Z ede	j                  › d	e	j                  › d
e	j                   › de	j"                  › �«        ej                  «       ez
  dz  Z eded›d�«       yyy)é    )Úannotations)Úcached_property)ÚPathc                  óÜ   — e Zd ZdZ ee«      j                  «       fdd„Zedd„«       Z	edd„«       Z
edd„«       Zedd„«       Zdd„Zedd„«       Zedd	„«       Zedd
„«       Zedd„«       Zy)ÚGitRepoa÷  Represent a local Git repository and expose branch, commit, and remote metadata.

    This class discovers the repository root by searching for a .git entry from the given path upward, resolves the
    actual .git directory (including worktrees), and reads Git metadata directly from on-disk files. It does not invoke
    the git binary and therefore works in restricted environments. All metadata properties are resolved lazily and
    cached; construct a new instance to refresh state.

    Attributes:
        root (Path | None): Repository root directory containing the .git entry; None if not in a repository.
        gitdir (Path | None): Resolved .git directory path; handles worktrees; None if unresolved.
        head (str | None): Raw contents of HEAD; a SHA for detached HEAD or "ref: <refname>" for branch heads.
        is_repo (bool): Whether the provided path resides inside a Git repository.
        branch (str | None): Current branch name when HEAD points to a branch; None for detached HEAD or non-repo.
        commit (str | None): Current commit SHA for HEAD; None if not determinable.
        origin (str | None): URL of the "origin" remote as read from gitdir/config; None if unset or unavailable.

    Examples:
        Initialize from the current working directory and read metadata
        >>> from pathlib import Path
        >>> repo = GitRepo(Path.cwd())
        >>> repo.is_repo
        True
        >>> repo.branch, repo.commit[:7], repo.origin
        ('main', '1a2b3c4', 'https://example.com/owner/repo.git')

    Notes:
        - Resolves metadata by reading files: HEAD, packed-refs, and config; no subprocess calls are used.
        - Caches properties on first access using cached_property; recreate the object to reflect repository changes.
    c                ó˜   — | j                  |«      | _        | j                  r!| j                  | j                  «      | _        yd| _        y)zèInitialize a Git repository context by discovering the repository root from a starting path.

        Args:
            path (Path, optional): File or directory path used as the starting point to locate the repository root.
        N)Ú
_find_rootÚrootÚ_gitdirÚgitdir)ÚselfÚpaths     úW/var/www/pod-logistic/pod-ai/venv/lib/python3.12/site-packages/ultralytics/utils/git.pyÚ__init__zGitRepo.__init__(   s4   € ð —O‘O DÓ)ˆŒ	Ø15·²�d—l‘l 4§9¡9Ó-ˆ�Àˆ�ó    c                óT   — t        d„ | gt        | j                  «      ¢D «       d«      S )zReturn repo root or None.c              3  óH   K  — | ]  }|d z  j                  «       sŒ|–— Œ y­w)ú.gitN)Úexists)Ú.0Úds     r   ú	<genexpr>z%GitRepo._find_root.<locals>.<genexpr>4   s   è ø€ ÒO˜1¸!¸f¹*×9LÑ9LÕ9N”QÑOùs   ‚"›"N)ÚnextÚlistÚparents©Úps    r   r	   zGitRepo._find_root1   s(   € ô ÑO Ð 5¤T¨!¯)©)£_Ð 5ÔOÐQUÓVÐVr   c                ó  — | dz  }|j                  «       r|S |j                  «       re|j                  d¬«      j                  «       }|j	                  d«      r4| |j                  dd«      d   j                  «       z  j                  «       S y)z2Resolve actual .git directory (handles worktrees).r   Úignore©Úerrorszgitdir:ú:é   N)Úis_dirÚis_fileÚ	read_textÚstripÚ
startswithÚsplitÚresolve)r
   ÚgÚts      r   r   zGitRepo._gitdir6   sx   € ð �6‰MˆØ�8‰8Œ:ØˆHØ�9‰9Œ;Ø—‘ 8�Ó,×2Ñ2Ó4ˆAØ�|‰|˜IÔ&Ø˜qŸw™w s¨A›¨qÑ1×7Ñ7Ó9Ñ9×BÑBÓDÐDØr   c                ój   — | r0| j                  «       r | j                  d¬«      j                  «       S dS )zRead and strip file if exists.r   r    N)r   r&   r'   r   s    r   Ú_readzGitRepo._readB   s-   € ñ 89¸Q¿X¹X¼Zˆq�{‰{ (ˆ{Ó+×1Ñ1Ó3ÐQÈTÐQr   c                ób   — | j                  | j                  r| j                  dz  «      S d«      S )zHEAD file contents.ÚHEADN)r.   r   ©r   s    r   ÚheadzGitRepo.headG   s*   € ð �z‰z°$·+²+˜$Ÿ+™+¨Ñ.ÓHÐHÀ4ÓHÐHr   c                ó„  — | j                   |z  }| j                  |«      x}r|S | j                   dz  }|j                  «       r|j                  «       j	                  «       ng }|j                  «       }|D ]H  }|dd dv sd|vrŒ|j                  dd«      \  }}	|	j                  «       |k(  sŒ8|j                  «       c S  y)z%Commit for ref (handles packed-refs).zpacked-refsNr#   )ó   #ó   ^ó    )	r   r.   r   Ú
read_bytesÚ
splitlinesÚencoder)   r'   Údecode)
r   ÚrefÚrfÚsÚpfÚbÚtgtÚlineÚshaÚnames
             r   Ú_ref_commitzGitRepo._ref_commitL   s¹   € à�[‰[˜3ÑˆØ—
‘
˜2“Ðˆ1ÐØˆHØ�[‰[˜=Ñ(ˆØ,.¯I©I¬KˆB�M‰M‹O×&Ñ&Ô(¸RˆØ�j‰j‹lˆØò 	$ˆDØ�B�Qˆx˜<Ñ'¨4°tÑ+;ØØŸ
™
 4¨Ó+‰IˆC�Ø�z‰z‹|˜sÓ"Ø—z‘z“|Ò#ð	$ð r   c                ó   — | j                   duS )zTrue if inside a git repo.N)r   r1   s    r   Úis_repozGitRepo.is_repo\   s   € ð �{‰{ $Ð&Ð&r   c                óæ   — | j                   r'| j                  r| j                  j                  d«      sy| j                  dd j                  «       }|j                  d«      r|t	        d«      d S |S )zCurrent branch or None.úref: Né   zrefs/heads/)rF   r2   r(   r'   Úlen)r   r;   s     r   ÚbranchzGitRepo.brancha   s`   € ð �|Š| 4§9¢9°D·I±I×4HÑ4HÈÔ4QØØ�i‰i˜˜ˆm×!Ñ!Ó#ˆØ,/¯N©N¸=Ô,Iˆs”3�}Ó%Ð'Ð(ÐRÈsÐRr   c                óÚ   — | j                   r| j                  sy| j                  j                  d«      r,| j                  | j                  dd j	                  «       «      S | j                  S )zCurrent commit SHA or None.NrH   rI   )rF   r2   r(   rD   r'   r1   s    r   ÚcommitzGitRepo.commiti   sU   € ð �|Š| 4§9¢9ØØ:>¿)¹)×:NÑ:NÈwÔ:Wˆt×Ñ §	¡	¨!¨" × 3Ñ 3Ó 5Ó6ÐfÐ]a×]fÑ]fÐfr   c                ó´  — | j                   sy| j                  dz  }d\  }}| j                  |«      xs dj                  «       D ]�  }|j	                  «       }|j                  d«      r"|j                  d«      r|j                  «       }ŒF|j                  «       j                  d«      sŒf|dk(  sŒl|j                  d	d
«      d
   j	                  «       } |S  |S )zOrigin URL or None.NÚconfig)NNÚ ú[ú]zurl =z[remote "origin"]ú=r#   )	rF   r   r.   r8   r'   r(   ÚendswithÚlowerr)   )r   ÚcfgÚremoteÚurlr=   r,   s         r   ÚoriginzGitRepo.originp   s¾   € ð �|Š|ØØ�k‰k˜HÑ$ˆØ ‰ˆ�Ø—*‘*˜S“/Ò' R×3Ñ3Ó5ò 	ˆAØ—‘“	ˆAØ�|‰|˜CÔ  Q§Z¡Z°¤_ØŸ™›‘Ø—‘“×%Ñ% gÕ.°6Ð=PÓ3PØ—g‘g˜c 1“o aÑ(×.Ñ.Ó0�ØØˆ
ð	ð ˆ
r   N)r   r   )r   r   ÚreturnúPath | None)r
   r   rZ   r[   )r   r[   rZ   ú
str | None)rZ   r\   )r;   ÚstrrZ   r\   )rZ   Úbool)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Ú__file__r*   r   Ústaticmethodr	   r   r.   r   r2   rD   ÚpropertyrF   rK   rM   rY   © r   r   r   r   	   sÎ   „ ññ< %)¨£N×$:Ñ$:Ó$<ô Eð òWó ðWð ò	ó ð	ð òRó ðRð òIó ðIóð  ò'ó ð'ð òSó ðSð ògó ðgð òó ñr   r   Ú__main__Nzrepo=z
branch=z
commit=z
origin=iè  u   
â�±ï¸� Profiling: total z.3fz ms)Ú
__future__r   Ú	functoolsr   Úpathlibr   r   r_   Útimer+   rF   Úperf_counterÚt0Úprintr
   rK   rM   rY   Údtrf   r   r   ú<module>rp      s±   ðõ #å %Ý ÷uñ uðp ˆzÒÛá‹	€AØ‡y‚yØˆT×ÑÓ ˆÙ��a—f‘f�X˜Y q§x¡x j°	¸!¿(¹(¸À9ÈQÏXÉXÈJÐWÔXØˆd×ÑÓ! BÑ&¨$Ñ.ˆÙÐ*¨2¨c¨(°#Ð6Õ7ð	 ð	 r   