Q%ddlZddlZddlmZmZddlmZddlmZm Z m Z m Z ddl m Z ddlmZddlmZdd lmZdd lmZmZmZmZmZmZdd lmZmZmZmZmZddl Z dd l!m"Z"ddl#Z#dd l$m%Z%ddl&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0ddl1m2Z2m3Z3e.r ddl4m5Z5ddl6m7Z7e#j8dZ9e9:e#j;dZ<Gddej=ee eZ>dS)N)PopenPIPE)IStream) hex_to_binActorStatsfinalize_process)Diffable)Git)Tree)base) SerializableTraversableIterableObj parse_datealtz_to_utctz_strparse_actor_and_datefrom_timestamp)timedaylightaltzonetimezone localtime)BytesIO) defaultdict) AnyIOIteratorListSequenceTupleUnion TYPE_CHECKINGcastDict)PathLikeLiteral)Repo)SymbolicReferencezgit.objects.commit)CommitcZeZdZUdZdZdZdZdZdZe de d<dZ d Z d=d d d e deed fdeed fdeed fded efdeed fdeed fded efdeee d fdeedd fdeed fdeed fdd ffd ZedddedfdZed d ddde fdZdeddfdZd edd ffd! Zedejfd"Zedejfd#Z edeee ffd$Z!d>d&ee"ee"fdedefd'Z#edefd(Z$e d>d d d)eedd*fd&ee"ee"fdede%df d+Z&d>d&ee"ee"fdede%dfd,Z'ede(fd-Z)ede*eeffd.Z+ede,eeeffd/Z-ede*ee,effd0Z.ed d d1ee/e0fde%dfd2Z1e d?d d deeefded4ed e,dfd5e2ded efded efd6ed eejfd7ed eejfddfd8Z3d9e4ddfd:Z5d9e4ddfd;Z6ede,efd<Z7xZ8S)@r*zWraps a git Commit object. This class will act lazily on some of its attributes and will query the value on demand only if it involves calling the git binary.GIT_AUTHOR_DATEGIT_COMMITTER_DATEzi18n.commitencodingzUTF-8committype) treeauthor authored_dateauthor_tz_offset committercommitted_datecommitter_tz_offsetmessageparentsencodinggpgsighexshaNrepor(binshar0r1r2r3r4r5r6r7r8r9r:returnctt|||||_|/t |t sJdt |z|||_|||_|||_ |||_ |||_ |||_ | | |_ | | |_| | |_| | |_| | |_dSdS)aInstantiate a new Commit. All keyword arguments taking None as default will be implicitly set on first query. :param binsha: 20 byte sha1 :param parents: tuple( Commit, ... ) is a tuple of commit ids or actual Commits :param tree: Tree object :param author: Actor is the author Actor object :param authored_date: int_seconds_since_epoch is the authored DateTime - use time.gmtime() to convert it into a different format :param author_tz_offset: int_seconds_west_of_utc is the timezone that the authored_date is in :param committer: Actor is the committer string :param committed_date: int_seconds_since_epoch is the committed DateTime - use time.gmtime() to convert it into a different format :param committer_tz_offset: int_seconds_west_of_utc is the timezone that the committed_date is in :param message: string is the commit message :param encoding: string encoding of the message, defaults to UTF-8 :param parents: List or tuple of Commit objects which are our parent(s) in the commit dependency graph :return: git.Commit :note: Timezone information is in the same format and in the same sign as what time.altzone returns. The sign is inverted compared to git's UTC timezone.Nz(Tree needs to be a Tree instance, was %s)superr*__init__r= isinstancer r/r0r1r2r3r4r5r6r7r8r9r:)selfr<r=r0r1r2r3r4r5r6r7r8r9r: __class__s /srv/buildsys-work-dir/castor/build_node/builder-2/WGSG1/unpkd_srcs/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/git/objects/commit.pyrAzCommit.__init__`sd fd$$T6222  dD)) b b+UX\]aXbXb+b b b)  DI   DK  $!.D   '$4D !  &DN  %"0D   *':D $  "DL  "DL  $DM   DKKK  )r*.c*t|jSN)tupler8)clsr.s rE_get_intermediate_itemszCommit._get_intermediate_itemssV^$$$rFct}|||}|d|jt |j||}|jS)zCalculate the sha of a commit. :param repo: Repo object the commit should be part of :param commit: Commit object for which to generate the sha r) r _serializetellseekodbstorerr/r=)rJr<r.stream streamlenistreams rE_calculate_sha_zCommit._calculate_sha_sf&!!!KKMM  A(..9f!E!EFF~rFkwargsc fdjD}|D]}|jvrtd||jjjfi|}j||_|S)zCreate new commit object from existing commit object. Any values provided as keyword arguments will replace the corresponding attribute in the new object. c2i|]}|t|S)getattr).0krCs rE z"Commit.replace..s%===GD!$$===rFzinvalid attribute name) __slots__ ValueErrorupdaterDr< NULL_BIN_SHArUr=)rCrVattrsattrname new_commits` rEreplacezCommit.replaces>===dn=== ; ;Ht~-- !9:::.  V#T^DIt/@JJEJJ  00JGG rFattrc<|tjvrd|jj|j\}}|_}|t| dStt| |dSrH) r*r^r<rPrRr=size _deserializerreadr@ _set_cache_)rCrf_binsha _typenamerRrDs rErkzCommit._set_cache_s 6# # #48IM4H4H4U4U 1GY 6   gfkkmm44 5 5 5 5 5 &$   + +D 1 1 1 1 1rFc6t|j|jSrH)rr2r3rCs rEauthored_datetimezCommit.authored_datetimesd0$2GHHHrFc6t|j|jSrH)rr5r6ros rEcommitted_datetimezCommit.committed_datetimesd143KLLLrFct|jtr!|jdddS|jdddS)z):return: First line of the commit message r r )rBr7strsplitros rEsummaryzCommit.summarysR dlC ( ( 3<%%dA..q1 1<%%eQ//2 2rFpathsc |r>t|jjj|jd|fi|St|jjj|jfi|S)aCount the number of commits reachable from this commit :param paths: is an optional path or a list of paths restricting the return value to commits actually containing the paths :param kwargs: Additional options to be passed to git-rev-list. They must not alter the output style of the command, or parsing will yield incorrect results :return: int defining the number of reachable commits--)lenr<gitrev_listr; splitlines)rCrzrVs rEcountz Commit.counts}  `-ty}-dk4QQ&QQ\\^^__ _)49=)$+@@@@KKMMNNNrFc@|jj|S)z :return: String describing the commits hex sha based on the closest Reference. Mostly useful for UI purposes)r<r~name_revros rErzCommit.name_revs y}%%d+++rFrevr)c d|vrtddg}|rIt|ttjfr|f}nt |}|||jj||fddi|}| ||S)anFind all commits matching the given criteria. :param repo: is the Repo :param rev: revision specifier, see git-rev-parse for viable options :param paths: is an optional path or list of paths, if set only Commits that include the path or paths will be considered :param kwargs: optional keyword arguments to git rev-list where ``max_count`` is the maximum number of commits to fetch ``skip`` is the number of commits to skip ``since`` all commits since i.e. '1970-01-01' :return: iterator yielding Commit itemsprettyz<--pretty cannot be used as parsing expects single sha's onlyr| as_processT) r_rBrvosr&rIextendr~r_iter_from_process_or_stream)rJr<rrzrV args_list paths_tupprocs rE iter_itemszCommit.iter_itemss* v  [\\ \ &*F  (%#r{!344 )"H !%LL   Y ' ' '!tx iKKDKFKK//d;;;rFc r|dd}|dkrd}||d<|j|j||fi|S)aAIterate _all_ parents of this commit. :param paths: Optional path or list of paths limiting the Commits to those that contain at least one of the paths :param kwargs: All arguments allowed by git-rev-list :return: Iterator yielding Commit objects which are parents of selfskipr r)getrr<)rCrzrVrs rE iter_parentszCommit.iter_parents1sNzz&!$$ 199Dvtty$@@@@@rFc|jst|jj|jdddd}d}|ddD])}|d\}}}||d|d|dz }*|}n9|jj|jd j|jddd }tj |j|S) zCreate a git stat from changes between this commit and its first parent or from all changes done if this is the very first commit. :return: git.Statsr|T)numstat no_renamesrootryr N rtr)rr) r8r<r~ diff_treer;rrwdiffr_list_from_string)rCtexttext2line insertions deletionsfilenames rEstatsz Commit.statsAs | p9=**4;dW[bf*ggDE))!""- L L48JJt4D4D1Y:::yyy(((KKDD9=%%dl1o&.\s/   1Aqt   rF) trailers_dictitemsros rEtrailerszCommit.trailersRs2  $ 2 8 8 : :    rFc gd}|jj|dt}|t |jdd}| }|sgSg}| dD]V}| dd\}}| | | fW|S) aGet the trailers of the message as a list Git messages can contain trailer information that are similar to RFC 822 e-mail headers (see: https://git-scm.com/docs/git-interpret-trailers). This functions calls ``git interpret-trailers --parse`` onto the message to extract the trailer information, returns the raw trailer data as a list. Valid message with trailer:: Subject line some body information another information key1: value1.1 key1: value1.2 key2 : value 2 with inner spaces Returned list will look like this:: [ ("key1", "value1.1"), ("key1", "value1.2"), ("key2", "value 2 with inner spaces"), ] :return: List containing key-value tuples of whitespace stripped trailer information. )r~zinterpret-trailersz--parseT)rrTrutf8rt:r ) r<r~executer communicatervr7encodedecodestriprwappend)rCcmdrtrailer trailer_listtkeyvals rE trailers_listzCommit.trailers_list`sF766"&)-"7"7VZ"7"["[''DL(9(9(@(@(B(BCCAFMMfUU--// I t$$ < 6 * * $!%88N$0'. ^Z 0 0 $!"n55N#F? 08::D ZZ\\F6{{R JJtQ// v;;"$$$&86&A$$$#dJv..// / / / 0 >6 * * -!%88N ^ , , , , , - -rFFparent_commitshead author_date commit_datec n|! |jjg}n<#t$rg}Yn.wxYw|D]'} t| |std| d|(|} t j} |ptj| }|ptj | }tt} totjdk}|rtnt }| |jd}|rt'|\}}n|rt'|\}}n| |}}| |jd}| rt'| \}}n|rt'|\}}n| |}}|jd\}}| |||j}t|t2st5dt|t2r||}|||j|||||||||| }||||_|rddl} |j ||n_#t$rR|j!j"#||jj$|d |z}|j%|d |zYnwxYw|S) a2Commit the given tree, creating a commit object. :param repo: Repo object the commit should be part of :param tree: Tree object or hex or bin sha the tree of the new commit :param message: Commit message. It may be an empty string if no message is provided. It will be converted to a string , in any case. :param parent_commits: Optional Commit objects to use as parents for the new commit. If empty list, the commit will have no parents at all and become a root commit. If None , the current head commit will be the parent of the new commit object :param head: If True, the HEAD will be advanced to the new commit automatically. Else the HEAD will remain pointing on the previous commit. This could lead to undesired results when diffing files. :param author: The name of the author, optional. If unset, the repository configuration is used to obtain this value. :param committer: The name of the committer, optional. If unset, the repository configuration is used to obtain this value. :param author_date: The timestamp for the author field :param commit_date: The timestamp for the committer field :return: Commit object representing the new commit :note: Additional information about the committer and Author are taken from the environment or from the git configuration, see git-commit-tree for more informationNzParent commit 'z' must be of type rry.z)conf_encoding could not be coerced to str)logmsgzcommit (initial): %szcommit: Switching to %s)&rr.r_rB config_readerrenvironrr4r1intrrrtm_isdstrrrenv_author_daterenv_committer_date conf_encodingrw get_valuedefault_encodingrv TypeErrorr0rarUr=git.refs set_commitrefsHeadcreateref set_reference)rJr<r0r7rrr1r4rrpcrenv unix_timeis_dstoffsetauthor_date_str author_time author_offsetcommitter_date_strcommitter_timecommitter_offset enc_section enc_optionrrdr~masters rEcreate_from_treezCommit.create_from_treesJV  ! $"&)"2!3 $ $ $!# $ $ U U!!S))U$%Sq%S%Sc%S%STTTU   ! !j4!4!4 +5<++KK 6ikk2Q6"0''#"5r::  ;)3K)@)@ &K  ;)3O)D)D &K)2FK!WWS%;R@@  A/9+/F/F ,N,,  A/9:L/M/M ,N,,/8&,N#&"3"9"9#">"> Z [*c>RSS --- IGHH H dC  #99T??DS                 //jAA   [ OOO [ $$Z$@@@@ [ [ [--IM1G; .  ''7PSY7Y'ZZZZZ [s  !!9IAJ21J2rRc B|j}|d|jzd|jD]#}|d|zd$|j}|j}|j}d}||d||j|jt|j fz|j |j}||d||j|j t|j fz|j |j |jkr&|d|j zd |dr_|d |jd d D]&}|d |zd zd'n#t&$rYnwxYw|d t)|jt,r)||j|j n||j|S) Nztree %s asciiz parent %s z%s %s <%s> %s %s r1r4z encoding %s r:sgpgsigrt ru)writer0rr8r1namer4emailr2rr3r9r5r6r__getattribute__r:rstriprwAttributeErrorrBr7rv) rCrRrraanamecfmtsiglines rErMzCommit._serializeysh  {TY&..w77888 7 7A E=1$,,W55 6 6 6 6 K N" G&%d&;<< fT]##  G'%d&>?? fT]##  =D1 1 1 E?T]2::7CC D D D $$X.. Bi   #{11$77==dCCBBGE3=4/77@@AAAA    D  e  dlC ( ( E$,%%dm44 5 5 5 5 E$,    s=F>c X|j}t|jt|dtjdzd|_g|_d} |}|ds|}no|j t||jt|d dt|j|_|}|}|}|d rS|}|d r|}|d |d S|j |_d|_|}|}|r|d d d kr?||d dzd |jd|_n|d ddkr||d dzddz} d} |} | sn3| d dd kr| }d} n| | ddz } @| d |jd|_| r|}| t'| |jd\|_|_|_n3#t.$r&t0d||jdYnwxYw t'| |jd\|_|_|_n3#t.$r&t0d||jdYnwxYw||_ |j |jd|_n8#t.$r+t0d|j|jdYnwxYw|S)z :param from_rev_list: if true, the stream format is coming from the rev-list command Otherwise it is assumed to be a plain data stream from our object r ryNTsparentrs mergetag  r s encoding ignoresgpgsig ruFrez3Failed to decode author line '%s' using encoding %s)exc_infoz6Failed to decode committer line '%s' using encoding %sz/Failed to decode message '%s' using encoding %s)rr r<rrwtree_idr0r8 startswithrr/rrIrr9r:rfindrrr1r2r3UnicodeDecodeErrorlogerrorr4r5r6rjr7) rCrRr next_line parent_line author_linecommitter_lineencbufsigis_next_headersigbufs rErizCommit._deserializes ?Jxxzz/?/?/A/A!/D$E$Et|WYGY[]^^    l"(**K)))44 '  L   T 49jARARATATUWAXA_A_`gAhAh6i6i j j k k k  lT\**  !HJJ ""<00 '  I&&t,, '$HJJ &&t,, '""<00 '-  iikk %1R4yL(( #CHHTNNQ$6$8$8 9 @ @PX Y Y QqSZ''#((4..1,../%7!&&%XZZF!ac{d**$llnn)-6!"":%C&"jj//66t}hOO !(**""$$C' %,  %[%7%7 y%Q%QRR   "%%!    IIE          %^%:%:4=)%T%TUU  #((!    IIH        {{}}  <..t}iHHDLL!    IIA          s6;L-L?>L?;M??-N/.N/ %O222P'&P'cg}|jrFtjd|jtj}|D]}|t ||S)z Search the commit message for any co-authors of this commit. Details on co-authors: https://github.blog/2018-01-29-commit-together-with-co-authors/ :return: List of co-authors for this commit (as Actor objects). z^Co-authored-by: (.*) <(.*?)>$)r7refindall MULTILINErr)rC co_authorsresultsr1s rErzCommit.co_authors!sc < 2j1  G " 2 2!!%.1111rF) NNNNNNNNNNN)ry)NFNNNN)9__name__ __module__ __qualname____doc__rrrrr/r'__annotations__r^_id_attribute_bytesr"r rrfloatrvr rA classmethodr!rKrUrrerkpropertydatetimerprrrxr&rrrrrrrr%rrrrrrrboolrrrMrir __classcell__)rDs@rEr*r*=sCC(O-*M'D'( &&& IN #'%)*./3(,+/26+/37%)#'K!K!K!K!D$J K! eTk" K! S$Y' K! e ,K!%K!c4i(K!#4;/K!sE4'(K!x)4/0K!T "K!c4i K! K!K!K!K!K!K!Z%X%% :N%%%[% 6 8    [ &22222222I8#4IIIXIMH$5MMMXM3sEz*333X3OO58H+=!=>OsOWZOOOO",#,,,X, 68 (<(<(<3"55 6(<Xx112 (<  (< (  (<(<(<[(r5s  """"""""????????????>============= ######                        ('''''''+******g,--"w"$$%%% w w w w w T[0(Lw w w w w rF