Skip to content

Instantly share code, notes, and snippets.

@yoshuawuyts
Created August 25, 2018 23:25
Show Gist options
  • Save yoshuawuyts/625e69c0c5bbb4ef39aff947a0ee2676 to your computer and use it in GitHub Desktop.
Save yoshuawuyts/625e69c0c5bbb4ef39aff947a0ee2676 to your computer and use it in GitHub Desktop.
#!/bin/sh
COMMIT_MSG_FILE=$1 # The git commit file.
COMMIT_SOURCE=$2 # The current commit message.
# Add "Signed-off-by: <user> <email>" to every commit message.
SOB=$(git var GIT_COMMITTER_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
git interpret-trailers --in-place --trailer "$SOB" "$COMMIT_MSG_FILE"
if test -z "$COMMIT_SOURCE"; then
/usr/bin/perl -i.bak -pe 'print "\n" if !$first_line++' "$COMMIT_MSG_FILE"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment