Skip to content

Instantly share code, notes, and snippets.

@rm3l
Created September 7, 2023 11:39
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 rm3l/ea53535cd1cb5e72da51eb2d8746e031 to your computer and use it in GitHub Desktop.
Save rm3l/ea53535cd1cb5e72da51eb2d8746e031 to your computer and use it in GitHub Desktop.
Git hook for adding `Signed-off-by` to commit message - inspired from https://stackoverflow.com/a/46536244
#!/bin/sh
NAME=$(git config user.name)
EMAIL=$(git config user.email)
if [ -z "$NAME" ]; then
echo "empty git config user.name"
exit 1
fi
if [ -z "$EMAIL" ]; then
echo "empty git config user.email"
exit 1
fi
git interpret-trailers --if-exists doNothing --trailer \
"Signed-off-by: $NAME <$EMAIL>" \
--in-place "$1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment