o
    ﯪg                     @   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r5ddlmZ de	d	ef d
e	d	ef f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&   dt dtdtf 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)	is_remote
ValueErrorpath)r   r   r    N/var/www/html/chatdoc2/venv/lib/python3.10/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dded	e	d
df fddZ
d
efddZ	d"deedef deedf d
d f fddZed
efddZe	d"dee dddeedf deded
ee fddZeed
efddZeed
ef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refsrepor   r   
check_pathr   Nc                    sF   |rt || jd st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__c                 C   s   | j S N)name)r   r   r   r   __str__I   s   zReference.__str__objectr   logmsgc                    sV   d}|dur| j j}|js|j| kr| jj}t || |dur)| j j|| | S )zqSpecial version which checks if the head-log needs an update as well.

        :return:
            self
        N)	r    headis_detachedrefcommitbinshar'   
set_object
log_append)r   r-   r.   	oldbinshar/   r)   r   r   r4   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clscommon_pathr   kwargsc                 O   s   |  ||S )zEquivalent to
        :meth:`SymbolicReference.iter_items <git.refs.symbolic.SymbolicReference.iter_items>`,
        but will return non-detached references as well.)_iter_items)r>   r    r?   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"   r8   )r   r9   r<   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"   r7   N)r   r9   r;   r<   r   r   r   remote_head   s   zReference.remote_head)Tr*   )r   
__module____qualname____doc__	__slots___points_to_commits_only_resolve_ref_on_creater%   r   boolr(   r#   r,   r   r   r4   propertyr+   classmethodr   r   r   r
   rB   r   rC   rD   __classcell__r   r   r)   r   r   )   sN     	
)

N)__all__git.utilr   r   symbolicr   r   typingr   r	   r
   r   r   r   	git.typesr   r   r   git.repor   r   r   r   r   r   r   <module>   s    "