Your IP : 216.73.216.85


Current Path : /opt/alt/python37/lib/python3.7/site-packages/pbr/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib/python3.7/site-packages/pbr/__pycache__/git.cpython-37.pyc

B

�V�&�@sddlmZddlZddlmZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlm
Z
d'dd�Zd	d
�Zdd�Zd
d�Zdd�Zd(dd�Zdd�Zdd�Zdd�Zd)dd�Zdd�Zd*dd�Zd d!�Zdejjddfd"d#�Zdd$e�fd%d&�ZdS)+�)�unicode_literalsN)�log)�optionsFTc	Cs�|rtj}tj}nd}d}tj��}|r2|�|�tj||||d�}|��}|jrl|rlt	j
�d||jf��t|�dks�|dr�|d�
�s�dS|d�
��dd�S)N)�stdout�stderr�envz%s returned %dr�zutf-8�replace)�
subprocess�PIPE�os�environ�copy�update�Popen�communicate�
returncode�	distutils�errors�DistutilsError�len�strip�decode)	�cmd�throw_on_error�bufferr�out_location�err_location�newenv�output�out�r!�8/opt/alt/python37/lib/python3.7/site-packages/pbr/git.py�_run_shell_command!s&


 r#cKs,t|ttf�s|g}tdd|g|f|�S)N�gitz--git-dir=%s)�
isinstance�list�tupler#)r�git_dir�kwargsr!r!r"�_run_git_command<sr*c
CsHytdddg�Stk
rB}z|jtjkr0dS�Wdd}~XYnXdS)Nr$z	rev-parsez	--git-dirr)r#�OSError�errno�ENOENT)�er!r!r"�_get_git_directoryCsr/cCs*ytddg�Wntk
r$dSXdS)Nr$z	--versionFT)r#r+r!r!r!r"�_git_is_installedMs
r0cCst|tjd�S)z�Find the highest tag from a list.

    Pass in a list of tag strings and this will return the highest
    (latest) as sorted by the pkg_resources version parser.
    )�key)�max�
pkg_resources�
parse_version)�tagsr!r!r"�_get_highest_tagXsr6rcCsLg}|dkrt�}|r>t�d�tddg|�}|�d�d��}dd�|D�S)	z�Behave like a file finder entrypoint plugin.

    We don't actually use the entrypoints system for this because it runs
    at absurd times. We only want to do this when we are building an sdist.
    Nz2[pbr] In git context, generating filelist from gitzls-filesz-z�zutf-8cSsg|]}|r|�qSr!r!)�.0�fr!r!r"�
<listcomp>psz#_find_git_files.<locals>.<listcomp>)�_run_git_functionsr�infor*�splitr)�dirnamer(�	file_listr!r!r"�_find_git_filesas
r@cCs6tddg|�}d|kr&|�dd�dSd|kr2dSdS)N�describez--always�-�����.r)r*�rsplit)r(rAr!r!r"�_get_raw_tag_infossrGcCst|�dkS)Nr)rG)r(r!r!r"�get_is_release|srHcCsd}t�rt�}|pdS)N)r0r/)r(r!r!r"r;�sr;cCs"|s
t�}|rtdddg|�SdS)z1Return the short sha for this repo, if it exists.rz-n1z--pretty=format:%hN)r;r*)r(r!r!r"�get_git_short_sha�srIccs�d}d}|dfVx�|D]~\}}}|r^t|�}t|�d}|sH|dfV|dt||d�fV|�d�s�|�d	�r~|dd
�}|dt|d�fVd
}qWdS)z�Convert a oneline log iterator to formatted strings.

    :param changelog: An iterator of one line log entries like
        that given by _iter_log_oneline.
    :return: An iterator over (release, formatted changelog) tuples.
    TNzCHANGES
=======

rB�
z%(tag)s
%(underline)s

)�tag�	underlinezMerge rE���z
* %(msg)s
)�msgF)r6r�dict�
startswith�endswith)�	changelog�
first_line�current_release�hashr5rNrLr!r!r"�_iter_changelog�s"



rVcCs|dkrt�}|sgSt|�S)aQIterate over --oneline log entries if possible.

    This parses the output into a structured form but does not apply
    presentation logic to the output - making it suitable for different
    uses.

    :return: An iterator of (hash, tags_set, 1st_line) tuples, or None if
        changelog generation is disabled / not available.
    N)r/�_iter_log_inner)r(r!r!r"�_iter_log_oneline�s

rXccs�t�d�dddg}t||�}x�|�d�D]�}|��}t|�dkrDq*|d�d�rnd	|krn|�d	�d��}nd
�|dd��}d|kr�td
d�|�d	�d�d�dd�D��}nt�}|d||fVq*WdS)aIterate over --oneline log entries.

    This parses the output intro a structured form but does not apply
    presentation logic to the output - making it suitable for different
    uses.

    :return: An iterator of (hash, tags_set, 1st_line) tuples.
    z[pbr] Generating ChangeLogrz	--onelinez
--decoraterJrC��(�)� Nztag:cSsg|]}|�d�d�qS)�,r)r=)r8rKr!r!r"r:�sz#_iter_log_inner.<locals>.<listcomp>rztag: )	rr<r*r=rrPr�join�set)r(�log_cmdrR�line�
line_partsrNr5r!r!r"rW�s 	


$rWc	Cs�t��}|si}t�|dd�}|r&dS|s@t|d�}|r@t|�}|sHdSt�d�tj�	|d�}tj�
|�r~t�|tj�s~dSt
j|ddd	��"}x|D]\}}	|�|	�q�WWdQRXt��}
t�d
|
|�dS)z-Write a changelog based on the git changelog.�skip_changelog�SKIP_WRITE_GIT_CHANGELOGN)r(z[pbr] Writing ChangeLog�	ChangeLog�wzutf-8)�encodingz![pbr] ChangeLog complete (%0.1fs))�timer�get_boolean_optionrXrVrr<r�pathr^�exists�access�W_OK�io�open�write)r(�dest_dir�option_dictrR�start�should_skip�
new_changelog�changelog_file�release�content�stopr!r!r"�write_git_changelog�s.

rzrEc
sht�|dd�}|rdSt��}tj�|d�}tj�|d�}tj�|�rXt�|tj�sXdSt	�
d�d�|dkrtt�}|�rJg}dd	g}|t||��
d
�7}�fdd�|D�}td|�}	t�d
|	tj�}
dd�|
D�}
||
7}tt|��}t|d��R}tj�|��r&t|d��}|�|���WdQRX|�d
�|�d
�d��WdQRXt��}
t	�
d|
|�dS)z&Create AUTHORS file using git commits.�skip_authors�SKIP_GENERATE_AUTHORSNz
AUTHORS.in�AUTHORSz[pbr] Generating AUTHORSz.(jenkins@review|infra@lists|jenkins@openstack)rz--format=%aN <%aE>rJcsg|]}t��|�s|�qSr!)�re�search)r8�a)�
ignore_emailsr!r"r:sz$generate_authors.<locals>.<listcomp>zCo-authored-by:.+cSs$g|]}|r|�dd�d���qS)�:rY)r=r)r8�signedr!r!r"r:s�wb�rbzutf-8z[pbr] AUTHORS complete (%0.1fs))rrirhrrjr^rkrlrmrr<r/r*r=r~�findall�	MULTILINE�sortedr_rorp�read�encode)r(rqrrrtrs�old_authors�new_authors�authors�git_log_cmd�co_authors_out�
co_authors�new_authors_fh�old_authors_fhryr!)r�r"�generate_authors�sD

r�)FTN)rN)N)N) �
__future__r�distutils.errorsrrr,rnrr~r
rhr3�pbrrr#r*r/r0r6r@rGrHr;rIrVrXrWrj�curdirrzrOr�r!r!r!r"�<module>s4

	
	


"