Skip to content

Instantly share code, notes, and snippets.

@jon-ruckwood
Last active October 5, 2021 10:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jon-ruckwood/1af7f8c31db89733fa53c33ff5c1b4b6 to your computer and use it in GitHub Desktop.
Save jon-ruckwood/1af7f8c31db89733fa53c33ff5c1b4b6 to your computer and use it in GitHub Desktop.
Git config and hook to add trailer automatically to commit messages
# Requires branch named in format `zz/key-1234/some-short-desc
# Results in commit with trailer:
# TASK: KEY-1234
#
[trailer "task"]
key = "Task: "
ifExists = replace
ifMissing = add
cmd = git rev-parse --abbrev-ref HEAD | awk -F/ '{ print toupper($2) }'
#!/bin/sh
COMMIT_MSG_FILE=$1
COMMIT_SOURCE=$2
SHA1=$3
git interpret-trailers --in-place "$COMMIT_MSG_FILE"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment