Skip to content

Instantly share code, notes, and snippets.

@Ajnasz
Last active January 8, 2018 13:53
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 Ajnasz/6ed8154c5c04750d582decee4fc81436 to your computer and use it in GitHub Desktop.
Save Ajnasz/6ed8154c5c04750d582decee4fc81436 to your computer and use it in GitHub Desktop.
#!/bin/sh
#
# An example hook script to check the commit log message.
# Called by "git commit" with one argument, the name of the file
# that has the commit message. The hook should exit with non-zero
# status after issuing an appropriate message if it wants to stop the
# commit. The hook is allowed to edit the commit message file.
#
# To enable this hook, rename this file to "commit-msg".
# Uncomment the below to add a Signed-off-by line to the message.
# Doing this in a hook is a bad idea in general, but the prepare-commit-msg
# hook is more suited to it.
#
# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1"
# This example requires top in first line
# Topic is /mything: .+/ or /myotherthing: .+/
test "" != "$(head -n 1 "$1" | grep '^[a-z\.]\+:')" || {
echo >&2 "ERR: No topic defined in commit message 1st line"
exit 1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment