
    $go                        d dl mZ d dlZd dlZd dlZd dlZd dlmZ d dlZd dl	m
Z
 d dlZd dlmZ erd dlmZ  ej        e          ZdZdd
ZddZddZddZ	 	 	 	 	 dddZdS )    )annotationsN)TYPE_CHECKING)version)Abort)MkDocsConfigz-Deployed {sha} with MkDocs version: {version}returnboolc                 &   	 t          j        g dt           j        t           j                  } n7# t          $ r* t                              d           t          d          w xY w|                                  |                                 dk    S )N)git	rev-parsez--is-inside-work-treestdoutstderrz6Could not find git - is it installed and on your path?Deployment Aborted!r   )	
subprocessPopenPIPEFileNotFoundErrorlogerrorr   communicatewait)procs    Y/var/www/html/netbox-4.1.3/venv/lib/python3.11/site-packages/mkdocs/commands/gh_deploy.py_is_cwd_git_repor      s    +999??
 
 

  + + +		JKKK)***+ 	99;;!s	   -0 4A$strc                    t          j        g d| pd t           j        t           j                  }|                                \  }}|                    d                                          }|S )N)r   r   z--shortHEAD)cwdr   r   utf-8)r   r   r   r   decodestrip)	repo_pathr   r   _shas        r   _get_current_shar&   %   sm    ///	  D   ""IFA
--
 
 
&
&
(
(CJ    remote_name#tuple[str, str] | tuple[None, None]c                l   d|  d}t          j        ddd|gt           j        t           j                  }|                                \  }}|                    d                                          }d|v r|                    dd	          \  }}n d
|v r|                    d
d	          \  }}ndS ||fS )Nzremote.z.urlr   configz--getr   r    zgithub.com/   zgithub.com:)NN)r   r   r   r   r!   r"   split)r(   remoter   r   r$   urlhostpaths           r   _get_remote_urlr2   2   s     ){(((F	'6*  D   ""IFA
--
 
 
&
&
(
(CYY}a00
dd	#		YY}a00
ddz:r'   branchNonec                   t          j        ddddd|  gt           j        t           j                  }|                                \  }}|                    d                                          }t          j        d|t          j        t          j	        z            }|r&t          j        |                                          nd }t          j        t          j                  }|st                              d	           d S ||k    r#t                              d
| d| d           d S ||k     r0t                              d| d| d           t'          d          d S )Nr   showz-sz--format=%szrefs/heads/r   r    z0\d+(\.\d+)+((a|b|rc)\d+)?(\.post\d+)?(\.dev\d+)?zCVersion check skipped: No version specified in previous deployment.z1Previous deployment was done with MkDocs version z*; you are deploying with a newer version ()zHDeployment terminated: Previous deployment was made with MkDocs version z6; you are attempting to deploy with an older version (z)). Use --ignore-version to deploy anyway.r   )r   r   r   r   r!   r"   researchXIr   parsegroupmkdocs__version__r   warninginfor   r   )r3   r   r   r$   msgm	previousvcurrentvs           r   _check_versionrF   H   s   	m-C6-C-CD  D   ""IFA
--
 
 
&
&
(
(C
	EsBDSUSWKXXA,-7aggii(((4I}V/00H +YZZZZZ	I		C	 C C7?C C C	
 	
 	
 	
 	
 
I				 W`    CK     	
 	
 	

 )*** 
	r'   Fr+   r   message
str | Nonec                >   t                      st                              d           | j        }| j        }|st          |           |t          }t          t          j	        
                    | j                            }|                    t          j        |          }t                              d| j        | j                   	 t#          j        | j        |||d|||d	  	         nH# t"          j        $ r6}	t                              d|	j                    t)          d          d }	~	ww xY wt          j	                            | j        d          }
t          j	                            |
          rt/          |
          5 }|                                                                }d d d            n# 1 swxY w Y   t                              d	|            t                              d
           d S t5          |          \  }}||t                              d           d S |                    dd          \  }}|                    d          r|d t;          d                    }d| d| d}t                              d|            d S )NzECannot deploy - this directory does not appear to be a git repository)r   r%   z2Copying '%s' to '%s' branch and pushing to GitHub.T)mesgr.   r3   pushforce	use_shell
no_historynojekyllz(Failed to deploy to GitHub with error: 
r   CNAMEzTBased on your CNAME file, your documentation should be available shortly at: http://zSNOTE: Your DNS records must be configured appropriately for your CNAME URL to work.z/Your documentation should be available shortly./r,   z.gitzhttps://z.github.io/z3Your documentation should shortly be available at: )r   r   r   remote_branchr(   rF   default_messager&   osr1   dirnameconfig_file_pathformatr>   r?   rA   site_dir
ghp_importGhpErrorrG   r   joinisfileopenreadr"   r2   r-   endswithlen)r+   rG   rL   rN   ignore_versionshellrR   r(   r%   e
cname_filef
cname_hostr0   r1   usernamerepor/   s                     r   	gh_deployri   d   s     [		YZZZ(M$K &}%%%!
27??6+BCC
D
DCnnV%7SnAAGHH<  +O !
	
 
	
 
	
 
	
 
	
  + + +		IaiIIJJJ)***+ fow77J	w~~j!! * 	*))J	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	*9,69 9	
 	
 	
 	a	
 	
 	
 	 --JD$|t|BCCCCCC++$==   	(3v;;,'D555d555LsLLMMMMMs*   
"C- -D2<1D--D2'F;;F?F?)r   r	   )r   r   )r(   r   r   r)   )r3   r   r   r4   )NFFFF)r+   r   rG   rH   r   r4   )
__future__r   loggingrT   r8   r   typingr   rY   	packagingr   r>   mkdocs.exceptionsr   mkdocs.config.defaultsr   	getLogger__name__r   rS   r   r&   r2   rF   ri    r'   r   <module>rs      sL   " " " " " "  				 				                            # # # # # # 4333333g!!E   
 
 
 
   ,+ + + +< 

EN EN EN EN EN EN ENr'   