Skip to content

Instantly share code, notes, and snippets.

@meonkeys
Created November 11, 2010 23:27
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 meonkeys/673438 to your computer and use it in GitHub Desktop.
Save meonkeys/673438 to your computer and use it in GitHub Desktop.
#!/bin/bash
while read oldrev newrev refname
do
if [[ $refname =~ (hotfixes)|(qa)|(dev) ]] ; then
echo "ensuring no trivial merges in $refname" >&2
for hash in $(git log --format=%H --merges $oldrev..$newrev)
do
echo "checking $hash" >&2
if [[ ($refname =~ /qa$ && "$(git log --format=%H ^$hash^2 qa | wc)" == "$(git log --format=%H qa | wc)")
|| ($refname =~ /dev$ && "$(git log --format=%H ^$hash^2 dev | wc)" == "$(git log --format=%H dev | wc)")
|| ($refname =~ /hotfixes$ && "$(git log --format=%H ^$hash^2 hotfixes | wc)" == "$(git log --format=%H hotfixes | wc)") ]]
then
echo "Please rebase first, trivial merges are not allowed in $refname." >&2
exit 1
fi
done
fi
done
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment