Viewing File: /opt/alt/python35/lib/python3.5/site-packages/pbr/__pycache__/git.cpython-35.opt-1.pyc



V&@s{ddlmZddlZddlmZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlm
Z
dddddZd	d
ZddZd
dZddZddddZddZddZddZdddZddZdddZd d!Zdejjddd"d#Zdd$ed%d&ZdS)')unicode_literalsN)log)optionsFTc	Cs|rtj}tj}nd}d}tjj}|rI|j|tj|d|d|d|}|j}|jr|rt	j
jd||jft|dks|ds|dj
rdS|dj
jddS)	Nstdoutstderrenvz%s returned %drzutf-8replace)
subprocessPIPEosenvironcopyupdatePopencommunicate
returncode	distutilserrorsZDistutilsErrorlenstripdecode)	cmdZthrow_on_errorbufferrZout_locationZerr_locationZnewenvoutputoutr/git.py_run_shell_command!s&	
		.rcKs9t|ttfs|g}tdd|g||S)Ngitz--git-dir=%s)
isinstancelisttupler)rgit_dirkwargsrrr_run_git_command<s	r%cCs\ytdddgSWn>tk
rW}z|jtjkrBdSWYdd}~XnXdS)Nrz	rev-parsez	--git-dirr)rOSErrorerrnoENOENT)errr_get_git_directoryCsr*cCs1ytddgWntk
r,dSYnXdS)Nrz	--versionFT)rr&rrrr_git_is_installedMs

	r+cCst|dtjS)zFind 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_resourcesZ
parse_version)tagsrrr_get_highest_tagXsr0rcCslg}|dkrt}|r[tjdtddg|}|jdjd}dd|DS)	zBehave 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-zszutf-8cSsg|]}|r|qSrr).0frrr
<listcomp>ps	z#_find_git_files.<locals>.<listcomp>)_run_git_functionsrinfor%splitr)dirnamer#Z	file_listrrr_find_git_filesas	
r8cCsItddg|}d|kr5|jdddSd|krEdSdS)Ndescribez--always-.r)r%rsplit)r#r9rrr_get_raw_tag_infossr?cCst|dkS)Nr)r?)r#rrrget_is_release|sr@cCs"d}trt}|p!dS)N)r+r*)r#rrrr4s		r4cCs/|st}|r+tdddg|SdS)z1Return the short sha for this repo, if it exists.rz-n1z--pretty=format:%hN)r4r%)r#rrrget_git_short_shas	rAccsd}d}|dfVx|D]\}}}|r~t|}t|d}|s`|dfV|dtd|d|fV|jd	s|jd
r|dd}|dtd
|fVd}qWdS)zConvert 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
=======

r:
z%(tag)s
%(underline)s

tag	underlinezMerge r<z
* %(msg)s
msgF)r0rdict
startswithendswith)	changelogZ
first_lineZcurrent_releasehashr/rFrDrrr_iter_changelogs"rMcCs)|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#rrr_iter_log_onelines

	rOccs!tjddddg}t||}x|jdD]}|j}t|dkrbq;|djdrd	|kr|jd	dj}nd
j|dd}d|krtd
d|jd	djdddD}n	t}|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
--decoraterBr;rE() Nztag:cSs#g|]}|jddqS),r)r6)r1rCrrrr3s	z#_iter_log_inner.<locals>.<listcomp>rztag: )	rr5r%r6rrIrjoinset)r#Zlog_cmdrKlineZ
line_partsrFr/rrrrNs 	
	0	rNcCs!tj}|si}tj|dd}|r7dS|s^td|}|r^t|}|shdStjdtjj	|d}tjj
|rtj|tjrdSt
j|ddd	+}x!|D]\}}	|j|	qWWdQRXtj}
tjd
|
|dS)z-Write a changelog based on the git changelog.Zskip_changelogZSKIP_WRITE_GIT_CHANGELOGNr#z[pbr] Writing ChangeLogZ	ChangeLogwencodingzutf-8z![pbr] ChangeLog complete (%0.1fs))timerget_boolean_optionrOrMrr5rpathrTexistsaccessW_OKioopenwrite)r#dest_diroption_dictrKstartshould_skipZ
new_changelogZchangelog_filereleaseZcontentstoprrrwrite_git_changelogs.	
rhr<cstj|dd}|rdStj}tjj|d}tjj|d}tjj|rtj|tjrdSt	j
dd|dkrt}|rg}dd	g}|t||j
d
7}fdd|D}td|}	tjd
|	tj}
dd|
D}
||
7}tt|}t|dh}tjj|rt|d}|j|jWdQRX|jd
j|d
jdWdQRXtj}
t	j
d|
|dS)z&Create AUTHORS file using git commits.Zskip_authorsZSKIP_GENERATE_AUTHORSNz
AUTHORS.inZAUTHORSz[pbr] Generating AUTHORSz.(jenkins@review|infra@lists|jenkins@openstack)rz--format=%aN <%aE>rBcs(g|]}tj|s|qSr)research)r1a)
ignore_emailsrrr3s	z$generate_authors.<locals>.<listcomp>zCo-authored-by:.+cSs2g|](}|r|jdddjqS):rE)r6r)r1signedrrrr3s	wbrbzutf-8z[pbr] AUTHORS complete (%0.1fs))rrZrYrr[rTr\r]r^rr5r*r%r6rifindall	MULTILINEsortedrUr`rareadencode)r#rbrcrerdZold_authorsZnew_authorsZauthorsZgit_log_cmdZco_authors_outZ
co_authorsZnew_authors_fhZold_authors_fhrgr)rlrgenerate_authorssD	
		

rv) Z
__future__rZdistutils.errorsrrr'r_rrir
rYr.Zpbrrrr%r*r+r0r8r?r@r4rArMrOrNr[curdirrhrHrvrrrr<module>s4
		
"
Back to Directory File Manager