@@ -336,7 +336,7 @@ def stats(self) -> Stats:
336
336
return Stats ._list_from_string (self .repo , text )
337
337
338
338
@property
339
- def trailers_list (self ) -> List [str ]:
339
+ def trailers_list (self ) -> List [Tuple [ str , str ] ]:
340
340
"""Get the trailers of the message as a list
341
341
342
342
Git messages can contain trailer information that are similar to RFC 822
@@ -361,23 +361,29 @@ def trailers_list(self) -> List[str]:
361
361
Returned list will look like this::
362
362
363
363
[
364
- "key1: value1.1",
365
- "key1: value1.2",
366
- "key2 : value 2 with inner spaces",
364
+ ( "key1", " value1.1") ,
365
+ ( "key1", " value1.2") ,
366
+ ( "key2", " value 2 with inner spaces") ,
367
367
]
368
368
369
369
370
370
:return:
371
- List containing whitespace stripped trailer information.
371
+ List containing key-value tuples of whitespace stripped trailer information.
372
372
"""
373
373
cmd = ["git" , "interpret-trailers" , "--parse" ]
374
374
proc : Git .AutoInterrupt = self .repo .git .execute (cmd , as_process = True , istream = PIPE ) # type: ignore
375
375
trailer : str = proc .communicate (str (self .message ).encode ())[0 ].decode ()
376
376
trailer = trailer .strip ()
377
- if trailer :
378
- return [t .strip () for t in trailer .split ("\n " )]
379
377
380
- return []
378
+ if not trailer :
379
+ return []
380
+
381
+ trailer_list = []
382
+ for t in trailer .split ("\n " ):
383
+ key , val = t .split (":" , 1 )
384
+ trailer_list .append ((key .strip (), val .strip ()))
385
+
386
+ return trailer_list
381
387
382
388
@property
383
389
def trailers_dict (self ) -> Dict [str , List [str ]]:
@@ -416,9 +422,8 @@ def trailers_dict(self) -> Dict[str, List[str]]:
416
422
Mapping trailer keys to a list of their corresponding values.
417
423
"""
418
424
d = defaultdict (list )
419
- for trailer in self .trailers_list :
420
- key , value = trailer .split (":" , 1 )
421
- d [key .strip ()].append (value .strip ())
425
+ for key , val in self .trailers_list :
426
+ d [key ].append (val )
422
427
return dict (d )
423
428
424
429
@classmethod
0 commit comments