
    g                    X    d dl mZ d dlZd dlZd dlmZ d dlmZ dZdZ	dZ
 G d d	      Zy)
    )annotationsN)Any)utilz/^https://(www\.)?github.com/(.+)/(.+)(?:.git)?$z#^git@github.com:(.+)/(.+)(?:.git)?$)      r   c                      e Zd Zd ZddZddZed        Zed        Zed        Z	ed        Z
ed        Zd	 Zdd
Zd Zy)GitRepoc                   d | _         	 dd l}|}|j                  |d      | _        | j                  j                  j                  | _         | j                   t
        k\  rK| j                  j                  j                  d      }t        j                  j                  ||      | _
        y y # t        $ r
 d | _        Y y w xY w)Nr   T)search_parent_directoriesz--show-toplevel)git_versiongitReporepoversion_infoMIN_GIT_VERSION	rev_parseospathrelpathmodule	Exception)selfr   r   git_packagegit_roots        G/var/www/openai/venv/lib/python3.12/site-packages/streamlit/git_util.py__init__zGitRepo.__init__"   s     48	
  #K#(((NDI#yy}}99D?299==223DE ggoodH= 3  	 DI	s   B B+ +B>=B>c                ,    t        j                  |       S N)r   repr_r   s    r   __repr__zGitRepo.__repr__<   s    zz$    c                h    | j                   duxr# | j                  duxr | j                  t        k\  S )zDTrue if there's a git repo here, and git.version >= MIN_GIT_VERSION.N)r   r   r   r    s    r   is_validzGitRepo.is_valid?   s;     IIT! 4  ,4  O3	
r"   c                    | j                         sy | j                  ry | j                  j                  j	                         S r   )r$   is_head_detachedr   active_branchtracking_branchr    s    r   r(   zGitRepo.tracking_branchG   s3    }}  yy&&6688r"   c                P    | j                         sy | j                  j                  S r   )r$   r   untracked_filesr    s    r   r*   zGitRepo.untracked_filesQ   s    }}yy(((r"   c                d    | j                         sy| j                  j                  j                  S )NF)r$   r   headis_detachedr    s    r   r&   zGitRepo.is_head_detachedX   s"    }}yy~~)))r"   c                    | j                         sy | j                  j                  j                  d       D cg c]  }|j                   c}S c c}w r   )r$   r   indexdiffa_path)r   items     r   uncommitted_fileszGitRepo.uncommitted_files_   s?    }}(,		(<(<T(BC(B(BCCCs   Ac                    | j                         sy 	 | j                         \  }}|j                   d| }t        | j                  j                  | d|             S # t        $ r g cY S w xY w)N/z..)r$   get_tracking_branch_remotenamelistr   iter_commitsr   )r   remotebranch_nameremote_branchs       r   ahead_commitszGitRepo.ahead_commitsf   ss    }}	"&"A"A"CFK%{{m1[M:M		..-;-/PQRR 	I	s   AA   A.-A.c                    | j                         sy | j                  }|y |j                  j                  d      ^}}dj	                  |      }| j
                  j                  |      |fS )Nr5   )r$   r(   r7   splitjoinr   r:   )r   r(   remote_namebranchr;   s        r   r6   z"GitRepo.get_tracking_branch_remotes   se    }}..".3399#>fhhv&yy,k99r"   c                    | j                         sy| j                         }|y|\  }}|j                  D ]8  }t        j                  t
        |      t        j                  t        |      8 y y)NFT)r$   r6   urlsrematchGITHUB_HTTP_URLGITHUB_SSH_URL)r   remote_infor:   _branchurls        r   is_github_repozGitRepo.is_github_repo   sf    }}557%;;C#.:88NC0<  r"   c                   | j                         sy | j                         }|y |\  }}d }|j                  D ]  }t        j                  t
        |      }t        j                  t        |      }|'|j                  d       d|j                  d       } n+|c|j                  d       d|j                  d       } n |y ||| j                  fS )Nr   r5         )	r$   r6   rD   rE   rF   rG   rH   groupr   )r   rI   r:   rB   r   rK   https_matchesssh_matchess           r   get_repo_infozGitRepo.get_repo_info   s    }}557$;;CHH_c:M((>37K('--a01=3F3Fq3I2JK&%++A./q1B1B11E0FG  <VT[[((r"   N)returnstr)rT   bool)__name__
__module____qualname__r   r!   r$   propertyr(   r*   r&   r3   r=   r6   rL   rS    r"   r   r	   r	   !   s    4 
 9 9 ) ) * * D D 
 
:&)r"   r	   )
__future__r   r   rE   typingr   	streamlitr   rG   rH   r   r	   r[   r"   r   <module>r_      s6    # 	 	   E7
 L) L)r"   