Skip to content

Instantly share code, notes, and snippets.

@mallocator
Created March 6, 2015 22:47
Show Gist options
  • Save mallocator/c10f0203d3b4a5de8b6e to your computer and use it in GitHub Desktop.
Save mallocator/c10f0203d3b4a5de8b6e to your computer and use it in GitHub Desktop.
A commit-msg hook for git that will that will reject any commits where the commit message is not prefixed with an task label.
#!/bin/bash
# save the file as <git_directory>/.git/hooks/commit-msg.d/task and chmod +x
#Replace issue and word length(4) with your label to check for
if [ "${1:0:4}" = "TASK-" ]; then
#Allow maven release plugin to make commits even without a task id
if [ "${1:0:22}" != "[maven-release-plugin]" ]; then
echo >&2 Commit Message is missing a Task ID
exit 1
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment