Created
February 21, 2018 11:53
-
-
Save vincelee888/bf309682f6fc1e22394c8342775347d4 to your computer and use it in GitHub Desktop.
blocks pushing of SAVEPOINT or parked work in progress commits - use: git config --global core.hooksPath /path/to/my/centralized/hooks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# blocks pushing of repo with "SAVEPOINT" or "park". | |
# Based on https://github.com/raven/git-prepush-recipes/blob/master/pre-push.sample | |
remote="$1" | |
url="$2" | |
z40=0000000000000000000000000000000000000000 | |
IFS=' ' | |
while read local_ref local_sha remote_ref remote_sha | |
do | |
if [ "$local_sha" = $z40 ] | |
then | |
echo "Deleting files, OK." | |
else | |
if [ "$remote_sha" = $z40 ] | |
then | |
# New branch, examine all commits | |
range="$local_sha" | |
else | |
# Update to existing branch, examine new commits | |
range="$remote_sha..$local_sha" | |
fi | |
# Check for foo commit | |
commit=`git rev-list -n 1 --grep '^SAVEPOINT\|^park' "$range"` | |
if [ -n "$commit" ] | |
then | |
echo "--------------" | |
echo "Did not push - contains work in progress commits" | |
echo "--------------" | |
exit 1 | |
fi | |
fi | |
done | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment