ó
    ‘óýj)8  ã                   óÖ   • S r / SQr " S S5      r SS\S\S\\\\   4   4S jjrS\S\S\4S	 jr	S
\\   S\S\\   4S jr
S\\   S\4S jr    SS\S\S\S\S\S\S\S\4S jjrg)ag  Git trailers parsing and manipulation.

This module provides functionality for parsing and manipulating Git trailers,
which are structured information blocks appended to commit messages.

Trailers follow the format:
    Token: value
    Token: value

They are similar to RFC 822 email headers and appear at the end of commit
messages after free-form content.
)ÚTrailerÚadd_trailer_to_messageÚformat_trailersÚparse_trailersc            	       ód   • \ rS rSrSrSS\S\S\SS4S jjrS	\S\4S
 jr	S\4S jr
S\4S jrSrg)r   é+   z¶Represents a single Git trailer.

Args:
    key: The trailer key/token (e.g., "Signed-off-by")
    value: The trailer value
    separator: The separator character used (default ':')
ÚkeyÚvalueÚ	separatorÚreturnNc                 ó(   • Xl         X l        X0l        g)z—Initialize a Trailer instance.

Args:
    key: The trailer key/token
    value: The trailer value
    separator: The separator character (default ':')
N©r   r	   r
   )Úselfr   r	   r
   s       Ú;/usr/local/lib/python3.13/site-packages/dulwich/trailers.pyÚ__init__ÚTrailer.__init__4   s   € ð ŒØŒ
Ø"�ó    Úotherc                 óê   • [        U[        5      (       d  [        $ U R                  UR                  :H  =(       a9    U R                  UR                  :H  =(       a    U R
                  UR
                  :H  $ )z Compare two Trailer instances for equality.

Args:
    other: The object to compare with

Returns:
    True if trailers have the same key, value, and separator
)Ú
isinstancer   ÚNotImplementedr   r	   r
   )r   r   s     r   Ú__eq__ÚTrailer.__eq__@   sV   € ô ˜%¤×)Ñ)Ü!Ð!à�H‰H˜Ÿ	™	Ñ!÷ 2Ø—
‘
˜eŸk™kÑ)÷2à—‘ %§/¡/Ñ1ð	
r   c                 ó\   • SU R                   < SU R                  < SU R                  < S3$ )z~Return a string representation suitable for debugging.

Returns:
    A string showing the trailer's key, value, and separator
zTrailer(key=z, value=z, separator=Ú)r   ©r   s    r   Ú__repr__ÚTrailer.__repr__Q   s-   € ð ˜dŸh™h™\¨°$·*±*±¸|ÈDÏNÉNÑK]Ð]^Ð_Ð_r   c                 óP   • U R                    U R                   SU R                   3$ )zzReturn the trailer formatted as it would appear in a commit message.

Returns:
    The trailer in the format "key: value"
Ú ©r   r
   r	   r   s    r   Ú__str__ÚTrailer.__str__Y   s&   € ð —(‘(�˜DŸN™NÐ+¨1¨T¯Z©Z¨LÐ9Ð9r   r    ©Ú:)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ústrr   ÚobjectÚboolr   r   r!   Ú__static_attributes__© r   r   r   r   +   sU   † ññ
#˜Cð 
#¨ð 
#¸ð 
#Àdõ 
#ð
˜Fð 
 tô 
ð"`˜#ô `ð:˜÷ :r   r   ÚmessageÚ
separatorsr   c                 óX  • U (       d  S/ 4$  U R                  S5      nUR                  SS9nSnSn[        [	        U5      S-
  SS5       H-  nX6   R                  5       R                  S	5      (       d  M+  Un  O   Ub  UO
[	        U5      nUnUS
:”  aA  X8S-
     R                  5       (       d'  US-  nUS
:”  a  X8S-
     R                  5       (       d  M'  Sn	[        US-
  S
S5       Ho  n
X:   R                  5       nU(       a,  US
   R                  5       (       d  [        X±5      (       d    O-Sn	U	(       d  MQ  X:S-
     R                  5       (       a  Mm  U
n  O   Uc  U / 4$ X4U n[        XÁ5      nUSU nU(       aI  US   R                  5       (       d1  UR                  5         U(       a  US   R                  5       (       d  M1  SR                  U5      nU(       a  UR                  S5      (       d  US-  nUR                  S5      U4$ ! [         a    U R                  S5      n GN
f = f)a‹  Parse trailers from a commit message.

Trailers are extracted from the input by looking for a group of one or more
lines that (i) is all trailers, or (ii) contains at least one Git-generated
or user-configured trailer and consists of at least 25% trailers.

The group must be preceded by one or more empty (or whitespace-only) lines.
The group must either be at the end of the input or be the last non-whitespace
lines before a line that starts with '---'.

Args:
    message: The commit message as bytes
    separators: Characters to recognize as trailer separators (default ':')

Returns:
    A tuple of (message_without_trailers, list_of_trailers)
r   úutf-8zlatin-1T)ÚkeependsNé   éÿÿÿÿz---é    FÚ Ú
)ÚdecodeÚUnicodeDecodeErrorÚ
splitlinesÚrangeÚlenÚlstripÚ
startswithÚstripÚrstripÚisspaceÚ_is_trailer_lineÚ_parse_trailer_linesÚpopÚjoinÚendswithÚencode)r/   r0   ÚtextÚlinesÚtrailer_startÚcutoff_lineÚiÚ
search_endÚcontent_endÚhas_trailerÚkÚlineÚtrailer_linesÚtrailersÚmessage_linesÚmessage_without_trailerss                   r   r   r   b   s-  € ö* Ø�RˆyÐð)Ø�~‰~˜gÓ&ˆð �O‰O TˆOÐ*€Eð €MØ€Kô ”3�u“: ‘> 2 rÖ*ˆØ‰8�?‰?Ó×'Ñ'¨×.Ó.ØˆKÙñ +ð !,Ñ 7‘¼SÀ»Z€Jð €KØ
˜‹/ %°a©Ñ"8×">Ñ">×"@Ñ"@Ø�qÑˆð ˜‹/ %°a©Ñ"8×">Ñ">×"@Ó"@ð €KÜ�; ‘? A rÖ*ˆØ‰x�‰Ó ˆÞ˜˜Q™Ÿ™×)Ñ)ô $ D×5Ñ5ÙØˆK÷ ˆ;˜u¨¡U™|×1Ñ1×3Ó3ØˆMÙñ +ð Ñà˜ˆ}Ðð ¨
Ð3€MÜ# MÓ>€Hð ˜.˜=Ð)€Mö  ¨bÑ 1× 7Ñ 7× 9Ñ 9Ø×ÑÔö  ¨bÑ 1× 7Ñ 7× 9Ó 9ð  "Ÿw™w }Ó5ÐÞÐ(@×(IÑ(IÈ$×(OÑ(OØ  DÑ(Ð à$×+Ñ+¨GÓ4°hÐ?Ð?øôE ó )Ø�~‰~˜iÓ(‹ð)ús   �H
 È
H)È(H)rR   c                 ó’   • U HA  nX ;   d  M
  U R                  US5      S   nU(       d  M(  [        S U 5       5      (       a  MA    g   g)aV  Check if a single line is a trailer line.

A trailer line contains one of the separator characters and the token
before the first separator is non-empty and free of whitespace.

Args:
    line: The line to check (trailing whitespace already removed)
    separators: Valid separator characters

Returns:
    True if the line is a trailer line
r4   r6   c              3   ó@   #   • U  H  oR                  5       v •  M     g 7f©N©rB   ©Ú.0Úcs     r   Ú	<genexpr>Ú#_is_trailer_line.<locals>.<genexpr>Ó   s   é € Ð#Bº°A§I¡I§K Kºùó   ‚TF)ÚsplitÚany)rR   r0   ÚsepÚkey_parts       r   rC   rC   Â   sE   € ó ˆØ�;Ø—z‘z # qÓ)¨!Ñ,ˆHçˆx¤Ñ#B¹Ó#B× BÓ BÙñ ð r   rJ   c                 óv  • / nSnU  GH  nUR                  5       nU(       d  U(       a  UR                  U5        SnM7  US   R                  5       (       a1  U(       a(  UR                  5       nU=R                  SU-   -  sl        M€  U(       a  UR                  U5        SnU Hu  nXu;   d  M
  UR                  US5      nUS   n	U	(       d  M*  [        S U	 5       5      (       a  MC  [        U5      S:”  a  US   R                  5       OSn
[        XšU5      n  GM     GM     U(       a  UR                  U5        U$ )z¥Parse individual trailer lines.

Args:
    lines: The trailer lines to parse
    separators: Valid separator characters

Returns:
    List of parsed Trailer objects
Nr6   r   r4   c              3   ó@   #   • U  H  oR                  5       v •  M     g 7frY   rZ   r[   s     r   r^   Ú'_parse_trailer_lines.<locals>.<genexpr>  s   é € Ð"<º°1§9¡9§; ;ºùr`   r7   )
rA   ÚappendrB   r>   r	   ra   rb   r=   r@   r   )rJ   r0   rT   Úcurrent_trailerrR   ÚstrippedÚcontinuationrc   Úpartsr   r	   s              r   rD   rD   Ø   s  € ð !€HØ&*€OäˆØ—;‘;“=ˆææØ—‘ Ô0Ø"&�Ùð �A‰;×Ñ× Ñ Þà'Ÿ™Ó0�Ø×%Ò%¨¨|Ñ);Ñ;Õ%Ùö Ø�O‰O˜OÔ,Ø"ˆOó ˆCØ�Ø Ÿ™ s¨AÓ.�Ø˜A‘h�÷ �3œsÑ"<¹Ó"<×<Ó<Ü03°E³
¸Q³˜E !™HŸN™NÔ,ÀB�EÜ&-¨c¸#Ó&>�OÛô ñ1 öH Ø�‰˜Ô(à€Or   rT   c                 ó˜   • U (       d  gU  Vs/ s H  n[        U5      PM     nnSR                  U5      R                  S5      S-   $ s  snf )z{Format a list of trailers as bytes.

Args:
    trailers: List of Trailer objects

Returns:
    Formatted trailers as bytes
r   r8   r2   ó   
)r*   rF   rH   )rT   ÚtrailerrJ   s      r   r   r     sF   € ö Øá)1Ó2ª˜gŒS�Ž\©€EÐ2Ø�9‰9�UÓ×"Ñ" 7Ó+¨eÑ3Ð3ùò 3s   �Ar   r	   r
   ÚwhereÚ	if_existsÚ
if_missingc                 óx  ^^• [        X5      u  px[        TTU5      n	[        U4S jU 5       5      n
U
(       d  US:X  a  U $ / UQU	PnGOUS:X  a  U $ US:X  a5  U Vs/ s H  oÌR                  T:w  d  M  UPM     nnUR	                  U	5        OÅUS:X  a&  [        UU4S jU 5       5      nU(       a  U $ / UQU	PnO™US:X  a�  Sn[        U5       Hl  u  püUR                  T:X  d  M  UR                  T:X  d  M)  Sn[        US-   [        U5      5       H  nUU   R                  T:X  d  M  S	n  O   U(       d  Mj  S	n  O   U(       d  U $ / UQU	PnO/ UQU	PnU=S
:X  a     U	/U Vs/ s H  oÌU	:w  d  M
  UPM     sn-   nOú=S:X  ap    / nS	nU HJ  nU(       d(  UR                  T:X  a  XÉ:w  a  UR	                  U	5        SnXÉ:w  d  M9  UR	                  U5        ML     U(       d  UR	                  U	5        UnO„S:X  a  / nSn[        U5       H=  u  püUR                  T:X  a  XÉ:w  a  [        U5      nXÉ:w  d  M,  UR	                  U5        M?     US:¼  a  UR                  US-   U	5        OUR	                  U	5        UnUnU(       a  UR                  S5      (       d  US-  nU(       a  US-  nU[        U5      -  nU$ s  snf s  snf )aø  Add a trailer to a commit message.

Args:
    message: The original commit message
    key: The trailer key
    value: The trailer value
    separator: The separator to use
    where: Where to add the trailer ('end', 'start', 'after', 'before')
    if_exists: How to handle existing trailers with the same key
        - 'add': Always add
        - 'replace': Replace all existing
        - 'addIfDifferent': Add only if value is different from all existing
        - 'addIfDifferentNeighbor': Add only if value differs from neighbors
        - 'doNothing': Don't add if key exists
    if_missing: What to do if the key doesn't exist
        - 'add': Add the trailer
        - 'doNothing': Don't add the trailer

Returns:
    The message with the trailer added
c              3   ó@   >#   • U  H  oR                   T:H  v •  M     g 7frY   )r   )r\   Útr   s     €r   r^   Ú)add_trailer_to_message.<locals>.<genexpr>B  s   øé € Ð=Ò+< a—U‘U˜c–\Ò+<ùs   ƒÚ	doNothingÚreplaceÚaddIfDifferentc              3   ól   >#   • U  H)  oR                   T:H  =(       a    UR                  T:H  v •  M+     g 7frY   )r   r	   )r\   ru   r   r	   s     €€r   r^   rv   S  s,   øé € ð !Ú;L°a—‘˜‘×1 §¡¨EÑ!1Ô1Ò;Lùs   ƒ14ÚaddIfDifferentNeighborTr4   FÚstartÚbeforeÚafterr5   r6   rn   )r   r   rb   r   rh   Ú	enumerater	   r<   r=   ÚinsertrG   r   )r/   r   r	   r
   rp   rq   rr   Úmessage_bodyÚexisting_trailersÚnew_trailerÚ
key_existsÚupdated_trailersru   Úhas_same_valueÚ
should_addrM   Úis_neighborÚjÚresultÚinsertedÚlast_key_indexÚresult_messages    ``                   r   r   r     sæ  ù€ ô< '5°WÓ&HÑ#€Lä˜#˜u iÓ0€Kô Ô=Ñ+<Ó=Ó=€JæØ˜Ó$ØˆNà<Ð.Ð<°Ð<Òð ˜Ó#ØˆNØ˜)Ó#á+<ÓMÒ+< aÇÁÈÁ§Ñ+<ÐÐMØ×#Ñ# KÕ0ØÐ*Ó*ä õ !Ù;Ló!ó ˆNö Ø�Ø@Ð!2Ð@°KÐ@ÑØÐ2Ó2àˆJô "Ð"3Ö4‘�Ø—5‘5˜C•< A§G¡G¨uÕ$4à"&�KÜ" 1 q¡5¬#Ð.?Ó*@ÖA˜Ø,¨QÑ/×3Ñ3°sÕ:Ø*/˜KÙ!ñ B÷ #�{Ø%*˜
Ùñ 5ö Ø�Ø@Ð!2Ð@°KÐ@Ñà@Ð!2Ð@°KÐ@Ðð ÞØ +˜}Ù+ó0Ú+�a°KÑ/?—Ñ+ñ0ñ  Ñö àˆFØˆHÛ%�Þ A§E¡E¨S£L°QÓ5EØ—M‘M +Ô.Ø#�HØÕ#Ø—M‘M !Ö$ñ &ö Ø—‘˜kÔ*Ø%ÑÜàˆFØˆNÜ!Ð"2Ö3‘�Ø—5‘5˜C“< AÓ$4Ü%(¨£[�NØÕ#Ø—M‘M !Ö$ñ	 4ð  Ó"Ø—‘˜n¨qÑ0°+Õ>à—‘˜kÔ*Ø%Ðð "€NÞ˜n×5Ñ5°e×<Ñ<Ø˜%ÑˆæØ˜%ÑˆØœ/Ð*:Ó;Ñ;ˆàÐùò]  NùòH0s   ÁJ2Á2J2Å	J7Å,J7Nr#   )r$   Úendr{   Úadd)r)   Ú__all__r   Úbytesr*   ÚtupleÚlistr   r,   rC   rD   r   r   r.   r   r   Ú<module>r”      s  ðñ,ò€÷4:ñ 4:ðr ñ]@Øð]@àð]@ð ˆ5�$�w‘-ÐÑ õ]@ð@˜3ð ¨Cð °Dô ð,4  S¡	ð 4°sð 4¸tÀG¹}ô 4ðn4˜d 7™mð 4°ô 4ð( ØØ-Øñ~Øð~à	ð~ð ð~ð ð	~ð
 ð~ð ð~ð ð~ð ö~r   