Skip to content

Instantly share code, notes, and snippets.

@javierg
Forked from iangreenleaf/funcs.sh
Created March 23, 2011 23:08
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 javierg/884230 to your computer and use it in GitHub Desktop.
Save javierg/884230 to your computer and use it in GitHub Desktop.
#!/bin/bash
##
## .git/hooks/post-merge
##
## Runs all special post-merge hooks
##
this_dir="$(dirname "$(test -L "$0" && readlink "$0" || echo "$0")")"
"$this_dir/require_signoff"
"$this_dir/require_ticket_number"
#!/bin/bash
##
## Checks for commits merged to master without a signoff
##
msg=`git log HEAD^..HEAD`
branch=`git branch 2>/dev/null | grep '^*' | cut -f2- -d' '`
if [ "$branch" != "master" ]; then
exit 0
elif [ -z "`echo "$msg" | grep '^[[:space:]]*Signed-off-by: '`" ]; then
echo -e >&2 \
"---------------------------------------------------------------------------------------------" \
"\n\033[5m\033[31mIt looks like you just merged an unsigned commit! You might want to fix that before you push.\033[0m" \
"\n---------------------------------------------------------------------------------------------"
exit 1
fi
#!/bin/bash
##
## Checks for commits merged to master without a ticket number
##
msg=`git log HEAD^..HEAD`
branch=`git branch 2>/dev/null | grep '^*' | cut -f2- -d' '`
if [ "$branch" != "master" ]; then
exit 0
elif [ -z "`echo "$msg" | grep -i 'fixes #[[:digit:]]\{1,5\}'`" ]; then
echo -e >&2 \
"---------------------------------------------------------------------------------------------------------" \
"\n\033[5m\033[31mIt looks like you just merged a commit with no ticket number! You might want to fix that before you push.\033[0m" \
"\n---------------------------------------------------------------------------------------------------------"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment