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:
- 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>"
}
- 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.
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()orgit.show(), trailers are returned as part of the commit message body and need to be manually parsed. For example:commit.bodycontains trailers as raw text:Adding native support for git trailers could looks like this:
trailersproperty to commit objects that contains parsed trailers as a structured object:commit.trailers:The implementation could leverage git's built-in
interpret-trailerscommand.