o
     {g                     @   s  g d Z ddlmZ ddlZddlZddlmZ ddlmZ ddl	m
Z
mZmZmZ ddlmZ erRddlmZ dd	lmZmZ dd
lmZ ddlmZ ddlmZ dedefddZdedefddZdddeddfddZded deddfdd ZG d!d" d"eZdS )#)
sm_sectionsm_namemkheadfind_first_remote_branchSubmoduleConfigParser    )BytesION)GitConfigParser)InvalidGitRepositoryError)AnySequenceTYPE_CHECKINGUnion)PathLike)ReferenceType)HeadRemoteReference)Remote)Repo   )	Submodulenamereturnc                 C   s   d|  dS )zA:return: Section title used in ``.gitmodules`` configuration filezsubmodule "" )r   r   r   w/var/www/bot.gig.net.ua/public_html/telegram/P1/HellBot/venv/lib/python3.10/site-packages/git/objects/submodule/util.pyr   %   s   r   sectionc                 C   s   |   } | dd S )z>:return: Name of the submodule as parsed from the section name   )strip)r   r   r   r   r   *   s   r   repor   pathr   c                 C   s   t | t j|S )z!:return: New branch/head instance)gitr   to_full_path)r   r    r   r   r   r   0   s   r   remotesr   branch_namer   c              	   C   s8   | D ]}z|j | W   S  ty   Y qw td| )ztFind the remote branch matching the name of the given branch or raise
    :exc:`~git.exc.InvalidGitRepositoryError`.z:Didn't find remote branch '%r' in any of the given remotes)refs
IndexErrorr	   )r#   r$   remoter   r   r   r   5   s   r   c                       sP   e Zd ZdZdededdf fddZdd
dZdddZd fddZ  Z	S )r   a  Catches calls to :meth:`~git.config.GitConfigParser.write`, and updates the
    ``.gitmodules`` blob in the index with the new data, if we have written into a
    stream.

    Otherwise it would add the local file to the index to make it correspond with the
    working tree. Additionally, the cache must be cleared.

    Please note that no mutating method will work in bare mode.
    argskwargsr   Nc                    s(   d | _ d | _d| _t j|i | d S )NT)_smref_index_auto_writesuper__init__)selfr(   r)   	__class__r   r   r.   R   s   zSubmoduleConfigParser.__init__	submoduler   c                 C   s   t || _dS )zaSet this instance's submodule. It must be called before the first write
        operation begins.N)weakrefrefr*   )r/   r2   r   r   r   set_submoduleY   s   z#SubmoduleConfigParser.set_submodulec                 C   sh   | j dusJ t| jtrJ |   }|dur2| j}|du r"|jj}|j|jg| j	d |
  dS dS )z5Flush changes in our configuration file to the index.N)write)r*   
isinstance_file_or_filesr   r+   r   indexaddk_modules_filer,   _clear_cache)r/   smr9   r   r   r   flush_to_index^   s   z$SubmoduleConfigParser.flush_to_indexc                    s   t   }|   |S )N)r-   r6   r>   )r/   rvalr0   r   r   r6   q   s   
zSubmoduleConfigParser.write)r2   r   r   N)r   N)
__name__
__module____qualname____doc__r
   r.   r5   r>   r6   __classcell__r   r   r0   r   r   G   s    


r   ) __all__ior   r3   r!   
git.configr   git.excr	   typingr
   r   r   r   	git.typesr   r   git.refsr   r   
git.remoter   git.repor   baser   strr   r   r   r   r   r   r   r   r   <module>   s&   