§
    l¬¸jÿ  ã                  óX  — d dl mZ d dl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        rk e	j        ¦   «         Z ede
j        › d	e
j        › d
e
j        › de
j        › de
j        › �
¦  «          e	j        ¦   «         ez
  dz  Z eded›d�¦  «         dS dS dS )é    )ÚannotationsN)Úcached_property)ÚPathc                  ó  — e Zd ZdZddd„Zedd	„¦   «         Zedd„¦   «         Zed d„¦   «         Zed!d„¦   «         Z	e
d"d„¦   «         Zd#d„Zd$d„Zed%d„¦   «         Ze
d"d„¦   «         Ze
d"d„¦   «         Ze
d"d„¦   «         Ze
d"d„¦   «         ZdS )&Ú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.
        refdir (Path | None): Directory containing shared refs, objects, and config; 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.
        message (str | None): Current commit subject from a loose object; 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())
        >>> is_repo = repo.is_repo
        >>> branch, commit, origin = repo.branch, repo.commit, repo.origin

    Notes:
        - Resolves metadata by reading files: HEAD, packed-refs, config, and objects; no subprocess calls are used.
        - Caches properties on first access using cached_property; recreate the object to reflect repository changes.
    NÚpathúPath | Nonec                ó  — |                       |p%t          t          ¦  «                             ¦   «         ¦  «        | _        | j        r|                      | j        ¦  «        nd| _        |                      | j        ¦  «        | _        dS )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_rootr   Ú__file__ÚresolveÚrootÚ_gitdirÚgitdirÚ_refdirÚrefdir)Úselfr   s     úe/root/private/project/pallet_detection_v2/.venv/lib/python3.11/site-packages/ultralytics/utils/git.pyÚ__init__zGitRepo.__init__)   sh   € ð —O’O DÐ$D­Dµ©N¬N×,BÒ,BÑ,DÔ,DÑEÔEˆŒ	Ø15´ÐD�d—l’l 4¤9Ñ-Ô-Ð-ÀˆŒØ—l’l 4¤;Ñ/Ô/ˆŒˆˆó    Úpr   Úreturnc                ó`   — t          d„ | gt          | j        ¦  «        ¢D ¦   «         d¦  «        S )zReturn repo root or None.c              3  óH   K  — | ]}|d z                        ¦   «         ¯|V — ŒdS )ú.gitN)Úexists)Ú.0Úds     r   ú	<genexpr>z%GitRepo._find_root.<locals>.<genexpr>6   s7   è è € ÐOÐO˜1¸!¸f¹*×9LÒ9LÑ9NÔ9NÐO�QÐOÐOÐOÐOÐOÐOr   N)ÚnextÚlistÚparents©r   s    r   r   zGitRepo._find_root3   s4   € õ ÐOÐO Ð 5¥T¨!¬)¡_¤_Ð 5ÐOÑOÔOÐQUÑVÔVÐVr   r   c                ód  — | dz  }|                      ¦   «         r|S |                     ¦   «         r€|                     d¬¦  «                             ¦   «         }|                     d¦  «        rC| |                     dd¦  «        d                              ¦   «         z                       ¦   «         S dS )z2Resolve actual .git directory (handles worktrees).r   Úignore©Úerrorszgitdir:ú:é   N)Úis_dirÚis_fileÚ	read_textÚstripÚ
startswithÚsplitr   )r   ÚgÚts      r   r   zGitRepo._gitdir8   s    € ð �6‰MˆØ�8Š8‰:Œ:ð 	ØˆHØ�9Š9‰;Œ;ð 	EØ—’ 8�Ñ,Ô,×2Ò2Ñ4Ô4ˆAØ�|Š|˜IÑ&Ô&ð EØ˜qŸwšw s¨A™œ¨qÔ1×7Ò7Ñ9Ô9Ñ9×BÒBÑDÔDÐDØˆtr   r   c                óÈ   — | r| dz  nd}t                                |¦  «        x}r<t          |¦  «        }|                     ¦   «         s| |z                       ¦   «         n|S | S )z7Resolve directory containing refs, objects, and config.Ú	commondirN)r   Ú_readr   Úis_absoluter   )r   r   Úsr   s       r   r   zGitRepo._refdirD   sj   € ð %+Ð4ˆF�[Ñ Ð °ˆÝ—’˜aÑ Ô Ð ˆ1ð 	HÝ�Q‘”ˆAØ12·²±´ÐG�F˜Q‘J×'Ò'Ñ)Ô)Ð)ÀaÐGØˆr   ú
str | Nonec                ó‚   — | r<|                       ¦   «         r(|                      d¬¦  «                             ¦   «         ndS )zRead and strip file if exists.r%   r&   N)r   r,   r-   r#   s    r   r4   zGitRepo._readM   s;   € ð 89ÐQ¸Q¿XºX¹Z¼ZÐQˆq�{Š{ (ˆ{Ñ+Ô+×1Ò1Ñ3Ô3Ð3ÈTÐQr   c                óN   — |                       | j        r
| j        dz  nd¦  «        S )zHEAD file contents.ÚHEADN)r4   r   ©r   s    r   ÚheadzGitRepo.headR   s)   € ð �zŠz°$´+ÐG˜$œ+¨Ñ.Ð.À4ÑHÔHÐHr   ÚrefÚstrc                óº  — | j         |z  }|                      |¦  «        x}r|S | j         dz  }|                     ¦   «         r&|                     ¦   «                              ¦   «         ng }|                     ¦   «         }|D ]Z}|dd…         dv sd|vrŒ|                     dd¦  «        \  }}	|	                     ¦   «         |k    r|                     ¦   «         c S Œ[dS )z%Commit for ref (handles packed-refs).zpacked-refsNr)   )ó   #ó   ^ó    )	r   r4   r   Ú
read_bytesÚ
splitlinesÚencoder/   r-   Údecode)
r   r=   Úrfr6   ÚpfÚbÚtgtÚlineÚshaÚnames
             r   Ú_ref_commitzGitRepo._ref_commitW   så   € àŒ[˜3ÑˆØ—
’
˜2‘”Ðˆ1ð 	ØˆHØŒ[˜=Ñ(ˆØ,.¯IªI©K¬KÐ?ˆB�MŠM‰OŒO×&Ò&Ñ(Ô(Ð(¸RˆØ�jŠj‰lŒlˆØð 	$ð 	$ˆDØ�B�Q�BŒx˜<Ð'Ð'¨4°tÐ+;Ð+;ØØŸ
š
 4¨Ñ+Ô+‰IˆC�Ø�zŠz‰|Œ|˜sÒ"Ð"Ø—z’z‘|”|Ð#Ð#Ð#ð #àˆtr   Úcommitc                óê  — | j         dz  |dd…         z  |dd…         z  }|                     ¦   «         sdS t          j        |                     ¦   «         ¦  «        }d|vrdS |                     dd¦  «        \  }}|                     d¦  «        rd|vrdS |                     dd¦  «        d                              ¦   «         d                              d	¬
¦  «         	                    ¦   «         }|pdS )z)Commit subject from loose object or None.ÚobjectsNé   ó    r)   s   commit s   

r   Úreplacer&   )
r   r   ÚzlibÚ
decompressrC   r/   r.   rD   rF   r-   )r   rO   ÚobjÚdataÚkindÚbodyÚsubjects          r   Ú_commit_subjectzGitRepo._commit_subjectg   sð   € àŒk˜IÑ%¨¨r°¨r¬
Ñ2°V¸A¸B¸B´ZÑ?ˆØ�zŠz‰|Œ|ð 	Ø�4ÝŒ˜sŸ~š~Ñ/Ô/Ñ0Ô0ˆØ˜ÐÐØ�4Ø—Z’Z  qÑ)Ô)‰
ˆˆdØ�Š˜zÑ*Ô*ð 	¨g¸TÐ.AÐ.AØ�4Ø—*’*˜W aÑ(Ô(¨Ô+×6Ò6Ñ8Ô8¸Ô;×BÒBÈ)ÐBÑTÔT×ZÒZÑ\Ô\ˆØˆ˜$Ðr   Úboolc                ó   — | j         duS )zTrue if inside a git repo.N)r   r;   s    r   Úis_repozGitRepo.is_repou   s   € ð Œ{ $Ð&Ð&r   c                óÚ   — | j         r!| j        r| j                             d¦  «        sdS | j        dd…                              ¦   «         }|                     d¦  «        r
|dd…         n|S )zCurrent branch or None.úref: Né   zrefs/heads/é   )r_   r<   r.   r-   )r   r=   s     r   ÚbranchzGitRepo.branchz   sq   € ð Œ|ð 	 4¤9ð 	°D´I×4HÒ4HÈÑ4QÔ4Qð 	Ø�4ØŒi˜˜˜Œm×!Ò!Ñ#Ô#ˆØŸ>š>¨-Ñ8Ô8ÐAˆs�2�3�3Œxˆx¸cÐAr   c                óÌ   — | j         r| j        sdS | j                             d¦  «        r4|                      | j        dd…                              ¦   «         ¦  «        n| j        S )zCurrent commit SHA or None.Nra   rb   )r_   r<   r.   rN   r-   r;   s    r   rO   zGitRepo.commit‚   sd   € ð Œ|ð 	 4¤9ð 	Ø�4Ø:>¼)×:NÒ:NÈwÑ:WÔ:WÐfˆt×Ò ¤	¨!¨"¨"¤× 3Ò 3Ñ 5Ô 5Ñ6Ô6Ð6Ð]aÔ]fÐfr   c                óV   — | j         r| j        sdS |                      | j        ¦  «        S )zCurrent commit subject or None.N)r_   rO   r\   r;   s    r   ÚmessagezGitRepo.message‰   s2   € ð Œ|ð 	 4¤;ð 	Ø�4Ø×#Ò# D¤KÑ0Ô0Ð0r   c                óî  — | j         sdS | j        dz  }d\  }}|                      |¦  «        pd                     ¦   «         D ]²}|                     ¦   «         }|                     d¦  «        r*|                     d¦  «        r|                     ¦   «         }ŒU|                     ¦   «                              d¦  «        r6|dk    r0|                     d	d
¦  «        d
                              ¦   «         } nŒ³|S )zOrigin URL or None.NÚconfig)NNÚ ú[ú]zurl =z[remote "origin"]ú=r)   )	r_   r   r4   rD   r-   r.   ÚendswithÚlowerr/   )r   ÚcfgÚremoteÚurlr6   r1   s         r   ÚoriginzGitRepo.origin�   sé   € ð Œ|ð 	Ø�4ØŒk˜HÑ$ˆØ ‰ˆ�Ø—*’*˜S‘/”/Ð' R×3Ò3Ñ5Ô5ð 	ð 	ˆAØ—’‘	”	ˆAØ�|Š|˜CÑ Ô ð  Q§Z¢Z°¡_¤_ð ØŸš™œ��Ø—’‘”×%Ò% gÑ.Ô.ð °6Ð=PÒ3PÐ3PØ—g’g˜c 1‘o”o aÔ(×.Ò.Ñ0Ô0�Ø�øØˆ
r   )N)r   r	   )r   r   r   r	   )r   r   r   r	   )r   r	   r   r	   )r   r	   r   r7   )r   r7   )r=   r>   r   r7   )rO   r>   r   r7   )r   r]   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Ústaticmethodr   r   r   r4   r   r<   rN   r\   Úpropertyr_   rd   rO   rg   rs   © r   r   r   r   
   s³  € € € € € ðð ð<0ð 0ð 0ð 0ð 0ð ðWð Wð Wñ „\ðWð ð	ð 	ð 	ñ „\ð	ð ðð ð ñ „\ðð ðRð Rð Rñ „\ðRð ðIð Ið Iñ „_ðIðð ð ð ð ð ð ð ð ð'ð 'ð 'ñ „Xð'ð ðBð Bð Bñ „_ðBð ðgð gð gñ „_ðgð ð1ð 1ð 1ñ „_ð1ð ðð ð ñ „_ðð ð r   r   Ú__main__zrepo=z
branch=z
commit=z	
message=z
origin=iè  u   
â�±ï¸� Profiling: total z.3fz ms)Ú
__future__r   rU   Ú	functoolsr   Úpathlibr   r   rt   Útimer0   r_   Úperf_counterÚt0Úprintr   rd   rO   rg   rs   Údtrz   r   r   ú<module>r„      sH  ðð #Ð "Ð "Ð "Ð "Ð "à €€€Ø %Ð %Ð %Ð %Ð %Ð %Ø Ð Ð Ð Ð Ð ðTð Tð Tð Tð Tñ Tô Tð Tðn ˆzÒÐØ€K€K€Kàˆ‰	Œ	€AØ„yð 8ØˆTÔÑ Ô ˆØˆÐl�a”fÐlÐl q¤xÐlÐl¸!¼(ÐlÐlÈaÌiÐlÐlÐbcÔbjÐlÐlÑmÔmÐmØˆdÔÑ!Ô! BÑ&¨$Ñ.ˆØˆÐ6¨2Ð6Ð6Ð6Ð6Ñ7Ô7Ð7Ð7Ð7ð Ðð8ð 8r   