a
    `Df                     @   s   d gZ ddlmZmZ ddlmZmZ ddlmZm	Z	m
Z
mZmZmZ ddlmZmZmZ erjddlmZ e	def e	def d	d
dZG dd  d eeeZdS )	Reference    )IterableObj	LazyMixin   )SymbolicReferenceT_References)AnyCallableIteratorTYPE_CHECKINGTypeUnion)AnyGitObjectPathLike_T)Repo.)funcreturnc                    s"   t ttd fdd} j|_|S )zZA decorator raising :exc:`ValueError` if we are not a valid remote, based on the
    path.)selfargsr   c                    s&   |   std| j  | g|R  S )Nz1ref path does not point to a remote reference: %s)Z	is_remote
ValueErrorpath)r   r   r    _/nfs/NAS7/SABIOD/METHODE/ermites/ermites_venv/lib/python3.9/site-packages/git/refs/reference.pywrapper   s    z(require_remote_ref_path.<locals>.wrapper)r   r   r   __name__)r   r   r   r   r   require_remote_ref_path   s    r   c                	       s   e Zd ZdZdZdZdZdZddee	dd fd	d
Z
edddZdeedef eedf d d fddZeedddZedee deedf eeee dddZeeedddZeeedddZ  ZS )r   zA named reference to any object.

    Subclasses may apply restrictions though, e.g., a :class:`~git.refs.head.Head` can
    only point to commits.
    r   FTrefsr   N)repor   
check_pathr   c                    sF   |r0t || jd s0td| jjd| |  t || dS )a  Initialize this instance.

        :param repo:
            Our parent repository.

        :param path:
            Path relative to the ``.git/`` directory pointing to the ref in question,
            e.g. ``refs/heads/master``.

        :param check_path:
            If ``False``, you can provide any path.
            Otherwise the path must start with the default path prefix of this type.
        /zCannot instantiate z from path N)str
startswith_common_path_defaultr   	__class__r   super__init__)r   r   r   r    r%   r   r   r'   6   s    zReference.__init__)r   c                 C   s   | j S )N)name)r   r   r   r   __str__I   s    zReference.__str__r   )objectlogmsgr   c                    sV   d}|dur,| j j}|js,|j| kr,| jj}t || |durR| j j|| | S )zqSpecial version which checks if the head-log needs an update as well.

        :return:
            self
        N)	r   headZis_detachedrefcommitZbinshar&   
set_objectZ
log_append)r   r+   r,   Z	oldbinshar-   r(   r   r   r0   O   s    
zReference.set_objectc                 C   s0   | j d}t|dk r| j S d|dd S )zi
        :return:
            (shortest) Name of this reference - it may contain path components
        r!         N)r   splitlenjoinr   tokensr   r   r   r)   x   s    zReference.name)clsr   common_pathr   kwargsr   c                 O   s   |  ||S )zEquivalent to
        :meth:`SymbolicReference.iter_items <git.refs.symbolic.SymbolicReference.iter_items>`,
        but will return non-detached references as well.)Z_iter_items)r8   r   r9   r   r:   r   r   r   
iter_items   s    zReference.iter_itemsc                 C   s   | j d}|d S )z
        :return:
            Name of the remote we are a reference of, such as ``origin`` for a reference
            named ``origin/master``.
        r!   r2   )r   r3   r6   r   r   r   remote_name   s    zReference.remote_namec                 C   s   | j d}d|dd S )z
        :return:
            Name of the remote head itself, e.g. ``master``.

        :note:
            The returned name is usually not qualified enough to uniquely identify a
            branch.
        r!   r1   N)r   r3   r5   r6   r   r   r   remote_head   s    zReference.remote_head)T)N)N)r   
__module____qualname____doc__	__slots__Z_points_to_commits_onlyZ_resolve_ref_on_creater$   r   boolr'   r"   r*   r   r   r0   propertyr)   classmethodr   r   r   r
   r;   r   r<   r=   __classcell__r   r   r(   r   r   )   s>   	 
) 

N)__all__Zgit.utilr   r   Zsymbolicr   r   typingr   r	   r
   r   r   r   Z	git.typesr   r   r   Zgit.repor   r   r   r   r   r   r   <module>   s     