Add trailer support for commit creation by Krishnachaitanyakc · Pull Request #2116 · gitpython-developers/GitPython
:param trailers: Optional trailer key-value pairs to append to the commit message. Can be a dictionary mapping trailer keys to values, or a list of ``(key, value)`` tuples (useful when the same key appears multiple times, e.g. multiple ``Signed-off-by`` trailers). Trailers are appended using ``git interpret-trailers``. See :manpage:`git-interpret-trailers(1)`.
:return: :class:`Commit` object representing the new commit.
# APPLY TRAILERS if trailers: trailer_args: List[str] = [] if isinstance(trailers, dict): for key, val in trailers.items(): trailer_args.append("--trailer") trailer_args.append(f"{key}: {val}") else: for key, val in trailers: trailer_args.append("--trailer") trailer_args.append(f"{key}: {val}")
cmd = [repo.git.GIT_PYTHON_GIT_EXECUTABLE, "interpret-trailers"] + trailer_args proc: Git.AutoInterrupt = repo.git.execute( # type: ignore[call-overload] cmd, as_process=True, istream=PIPE, ) stdout_bytes, _ = proc.communicate(str(message).encode()) finalize_process(proc) message = stdout_bytes.decode("utf8") # END apply trailers
# CREATE NEW COMMIT new_commit = cls( repo,