Last active
April 19, 2021 09:31
-
-
Save dixudx/7d7edea35b4d91e1a2a8fbf41d0954fa to your computer and use it in GitHub Desktop.
automatically sign-off new commits
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# usage: | |
# run command | |
# $ cd your-repo | |
# $ curl -Ls https://gist.githubusercontent.com/dixudx/7d7edea35b4d91e1a2a8fbf41d0954fa/raw/prepare-commit-msg -o .git/hooks/prepare-commit-msg | |
# $ chmod +x .git/hooks/prepare-commit-msg | |
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