@@ -336,7 +336,7 @@ def stats(self) -> Stats:
336336 return Stats ._list_from_string (self .repo , text )
337337
338338 @property
339- def trailers_list (self ) -> List [str ]:
339+ def trailers_list (self ) -> List [Tuple [ str , str ] ]:
340340 """Get the trailers of the message as a list
341341
342342 Git messages can contain trailer information that are similar to RFC 822
@@ -361,23 +361,29 @@ def trailers_list(self) -> List[str]:
361361 Returned list will look like this::
362362
363363 [
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") ,
367367 ]
368368
369369
370370 :return:
371- List containing whitespace stripped trailer information.
371+ List containing key-value tuples of whitespace stripped trailer information.
372372 """
373373 cmd = ["git" , "interpret-trailers" , "--parse" ]
374374 proc : Git .AutoInterrupt = self .repo .git .execute (cmd , as_process = True , istream = PIPE ) # type: ignore
375375 trailer : str = proc .communicate (str (self .message ).encode ())[0 ].decode ()
376376 trailer = trailer .strip ()
377- if trailer :
378- return [t .strip () for t in trailer .split ("\n " )]
379377
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
381387
382388 @property
383389 def trailers_dict (self ) -> Dict [str , List [str ]]:
@@ -416,9 +422,8 @@ def trailers_dict(self) -> Dict[str, List[str]]:
416422 Mapping trailer keys to a list of their corresponding values.
417423 """
418424 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 )
422427 return dict (d )
423428
424429 @classmethod
0 commit comments