Skip to content

Support Git trailers in commit messagesΒ #1046

@Ndpnt

Description

@Ndpnt

In the OpenTermsArchive engine we use git trailers to store record metadata in commits. And currently we need to manually parse and format them. It would be valuable to have native support for git trailers in simple-git, allowing direct access to trailer metadata as structured data.

Currently, when retrieving commits using git.log() or git.show(), trailers are returned as part of the commit message body and need to be manually parsed. For example:

const commit = await git.log();

commit.body contains trailers as raw text:

Commit message

Signed-off-by: John Doe <john@example.com>
Reviewed-by: Jane Smith <jane@example.com>

Adding native support for git trailers could looks like this:

  1. Add a trailers property to commit objects that contains parsed trailers as a structured object:
const commit = await git.log();

commit.trailers:

{
   "signed-off-by": "John Doe <john@example.com>",
   "reviewed-by": "Jane Smith <jane@example.com>"
}
  1. Add support for formatting trailers when creating commits:
await git.commit('Commit message', ['file.txt'], {
  trailers: {
    'Signed-off-by': 'John Doe <john@example.com>',
    'Reviewed-by': 'Jane Smith <jane@example.com>'
  }
});

The implementation could leverage git's built-in interpret-trailers command.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions