Skip to content

Commit 7cdf9c7

Browse files
CopilotByron
andauthored
Normalize interpret-trailers subprocess IO
Agent-Logs-Url: https://github.com/gitpython-developers/GitPython/sessions/1a855cb6-0111-4f52-b48d-46417aec5bde Co-authored-by: Byron <63622+Byron@users.noreply.github.com>
1 parent bd58716 commit 7cdf9c7

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

git/objects/commit.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -450,7 +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-
trailer = self._interpret_trailers(self.repo, self.message, ["--parse"], self.encoding).strip()
453+
trailer = self._interpret_trailers(self.repo, self.message, ["--parse"]).strip()
454454

455455
if not trailer:
456456
return []
@@ -462,17 +462,17 @@ def trailers_list(self) -> List[Tuple[str, str]]:
462462

463463
return trailer_list
464464

465-
@staticmethod
466-
def _interpret_trailers(repo: "Repo", message: str, trailer_args: Sequence[str], encoding: str) -> str:
465+
@classmethod
466+
def _interpret_trailers(cls, repo: "Repo", message: str, trailer_args: Sequence[str]) -> str:
467467
cmd = [repo.git.GIT_PYTHON_GIT_EXECUTABLE, "interpret-trailers", *trailer_args]
468468
proc: Git.AutoInterrupt = repo.git.execute( # type: ignore[call-overload]
469469
cmd,
470470
as_process=True,
471471
istream=PIPE,
472472
)
473-
stdout_bytes, _ = proc.communicate(message.encode(encoding, errors="strict"))
473+
stdout_bytes, _ = proc.communicate(message.encode(cls.default_encoding, errors="strict"))
474474
finalize_process(proc)
475-
return stdout_bytes.decode(encoding, errors="strict")
475+
return stdout_bytes.decode(cls.default_encoding, errors="strict")
476476

477477
@property
478478
def trailers_dict(self) -> Dict[str, List[str]]:
@@ -704,7 +704,7 @@ def create_from_tree(
704704
trailer_args.append("--trailer")
705705
trailer_args.append(f"{key}: {val}")
706706

707-
message = cls._interpret_trailers(repo, str(message), trailer_args, conf_encoding)
707+
message = cls._interpret_trailers(repo, str(message), trailer_args)
708708
# END apply trailers
709709

710710
# CREATE NEW COMMIT

0 commit comments

Comments
 (0)