@@ -450,14 +450,7 @@ def trailers_list(self) -> List[Tuple[str, str]]:
450450 :return:
451451 List containing key-value tuples of whitespace stripped trailer information.
452452 """
453- cmd = ["git" , "interpret-trailers" , "--parse" ]
454- proc : Git .AutoInterrupt = self .repo .git .execute ( # type: ignore[call-overload]
455- cmd ,
456- as_process = True ,
457- istream = PIPE ,
458- )
459- trailer : str = proc .communicate (str (self .message ).encode ())[0 ].decode ("utf8" )
460- trailer = trailer .strip ()
453+ trailer = self ._interpret_trailers (self .repo , self .message , ["--parse" ], self .encoding ).strip ()
461454
462455 if not trailer :
463456 return []
@@ -469,6 +462,18 @@ def trailers_list(self) -> List[Tuple[str, str]]:
469462
470463 return trailer_list
471464
465+ @staticmethod
466+ def _interpret_trailers (repo : "Repo" , message : str , trailer_args : Sequence [str ], encoding : str ) -> str :
467+ cmd = [repo .git .GIT_PYTHON_GIT_EXECUTABLE , "interpret-trailers" , * trailer_args ]
468+ proc : Git .AutoInterrupt = repo .git .execute ( # type: ignore[call-overload]
469+ cmd ,
470+ as_process = True ,
471+ istream = PIPE ,
472+ )
473+ stdout_bytes , _ = proc .communicate (message .encode (encoding , errors = "strict" ))
474+ finalize_process (proc )
475+ return stdout_bytes .decode (encoding , errors = "strict" )
476+
472477 @property
473478 def trailers_dict (self ) -> Dict [str , List [str ]]:
474479 """Get the trailers of the message as a dictionary.
@@ -699,15 +704,7 @@ def create_from_tree(
699704 trailer_args .append ("--trailer" )
700705 trailer_args .append (f"{ key } : { val } " )
701706
702- cmd = [repo .git .GIT_PYTHON_GIT_EXECUTABLE , "interpret-trailers" ] + trailer_args
703- proc : Git .AutoInterrupt = repo .git .execute ( # type: ignore[call-overload]
704- cmd ,
705- as_process = True ,
706- istream = PIPE ,
707- )
708- stdout_bytes , _ = proc .communicate (str (message ).encode ())
709- finalize_process (proc )
710- message = stdout_bytes .decode ("utf8" )
707+ message = cls ._interpret_trailers (repo , str (message ), trailer_args , conf_encoding )
711708 # END apply trailers
712709
713710 # CREATE NEW COMMIT
0 commit comments