Skip to content

Instantly share code, notes, and snippets.

@Mauin
Created September 7, 2016 20:20
Show Gist options
  • Save Mauin/96709b1e6cd558266f2dc6be19ed842c to your computer and use it in GitHub Desktop.
Save Mauin/96709b1e6cd558266f2dc6be19ed842c to your computer and use it in GitHub Desktop.
COURAGE - commit-msg git hook
#!/bin/sh
#
# Prepend the branch name to the commit message
#
# Add this file as [repo]/.git/hooks/prepare-commit-msg
#
# A couple notes:
# 1. The file must be executable (chmod +x commit-msg)
# 2. This works on a per-repo basis (unless you follow this guide https://coderwall.com/p/jp7d5q/create-a-global-git-commit-hook)
files_with_nocommit=$(git diff --cached --name-only --diff-filter=ACM HEAD | xargs grep -i "TODO" -l | tr '\n' ' ')
if [ "x${files_with_nocommit}x" != "xx" ]; then
sed -i.bak -e "1s/^/[COURAGE] /" $1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment