U V&@sddlmZddlZddlmZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl m Z d'ddZd d Zd d Zd dZddZd(ddZddZddZddZd)ddZddZd*ddZd d!Zdejjddfd"d#Zdd$efd%d&ZdS)+)unicode_literalsN)log)optionsFTc Cs|rtj}tj}nd}d}tj}|r2||tj||||d}|}|jrl|rlt j d||jft |dks|dr|d sdS|d ddS)N)stdoutstderrenvz%s returned %drutf-8replace) subprocessPIPEosenvironcopyupdatePopen communicate returncode distutilserrorsDistutilsErrorlenstripdecode) cmdZthrow_on_errorbufferrZ out_locationZ err_locationZnewenvoutputoutr8/opt/alt/python38/lib/python3.8/site-packages/pbr/git.py_run_shell_command!s*     r cKs,t|ttfs|g}tdd|g|f|S)Ngitz --git-dir=%s) isinstancelisttupler )rgit_dirkwargsrrr_run_git_command<sr'c CsPztdddgWStk rJ}z|jtjkr8WY dSW5d}~XYnXdS)Nr!z rev-parsez --git-dirr)r OSErrorerrnoZENOENT)errr_get_git_directoryCs   r+cCs,ztddgWntk r&YdSXdS)Nr!z --versionFT)r r(rrrr_git_is_installedMs r,cCst|tjdS)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_tagXsr1rcCsLg}|dkrt}|r>tdtddg|}|dd}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-zr cSsg|] }|r|qSrr).0frrr psz#_find_git_files..)_run_git_functionsrinfor'splitr)dirnamer%Z file_listrrr_find_git_filesas r:cCs6tddg|}d|kr&|dddSd|kr2dSdS)Ndescribez--always-.r)r'rsplit)r%r;rrr_get_raw_tag_infoss rAcCs t|dkS)Nr)rAr%rrrget_is_release|srCcCsd}trt}|pdS)N)r,r+rBrrrr6sr6cCs"|s t}|rtdddg|SdS)z1Return the short sha for this repo, if it exists.rz-n1z--pretty=format:%hN)r6r'rBrrrget_git_short_shasrDccsd}d}|dfV|D]~\}}}|r\t|}t|d}|sF|dfV|dt||dfV|ds|d r||dd }|d t|d fVd }qdS)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)r1rdict startswithendswith) changelogZ first_lineZcurrent_releasehashr0rIrGrrr_iter_changelogs&       rOcCs|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_innerrBrrr_iter_log_onelines rQccstddddg}t||}|dD]}|}t|dkrBq(|ddrld |krl|d d}nd |dd }d |krtd d|d dddd D}nt}|d||fVq(d S)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 --decoraterEr=() Nztag:cSsg|]}|ddqS),r)r8)r3rFrrrr5sz#_iter_log_inner..rztag: ) rr7r'r8rrKrjoinset)r%Zlog_cmdrMlineZ line_partsrIr0rrrrPs     rPc Cst}|si}t|dd}|r&dS|s@t|d}|r@t|}|sHdStdtj |d}tj |r~t |tj s~dSt j|ddd }|D]\}} || qW5QRXt} td | |dS) z-Write a changelog based on the git changelog.Zskip_changelogZSKIP_WRITE_GIT_CHANGELOGNrBz[pbr] Writing ChangeLogZ ChangeLogwr )encodingz![pbr] ChangeLog complete (%0.1fs))timerget_boolean_optionrQrOrr7r pathrWexistsaccessW_OKioopenwrite) r%dest_dir option_dictrMstart should_skipZ new_changelogZchangelog_filereleaseZcontentstoprrrwrite_git_changelogs2     rkr?c sht|dd}|rdSt}tj|d}tj|d}tj|rXt|tjsXdSt dd|dkrtt }|rJg}dd g}|t || d 7}fd d |D}t d|} td | tj} dd | D} || 7}tt|}t|dR} tj|r&t|d} | | W5QRX| d |d dW5QRXt} t 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>rEcsg|]}t|s|qSr)research)r3aZ ignore_emailsrrr5s z$generate_authors..zCo-authored-by:.+cSs$g|]}|r|dddqS):rR)r8r)r3Zsignedrrrr5swbrbr z[pbr] AUTHORS complete (%0.1fs))rr]r\r r^rWr_r`rarr7r+r'r8rlfindall MULTILINEsortedrXrcrdreadencode)r%rerfrhrgZ old_authorsZ new_authorsZauthorsZ git_log_cmdZco_authors_outZ co_authorsZnew_authors_fhZold_authors_fhrjrrorgenerate_authorssN       rx)FTN)rN)N)N) Z __future__rdistutils.errorsrrr)rbr rlr r\r/Zpbrrr r'r+r,r1r:rArCr6rDrOrQrPr^curdirrkrJrxrrrrs8          "