Created
January 5, 2014 11:48
-
-
Save kazu634/8267388 to your computer and use it in GitHub Desktop.
Gitのpre-push hook用スクリプト。git-nowコマンドと一緒に使うことを想定しています。
This file contains hidden or 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 | |
z40=0000000000000000000000000000000000000000 | |
IFS=' ' | |
while read local_ref local_sha remote_ref remote_sha | |
do | |
if [ "$local_sha" = $z40 ] | |
then | |
# Handle delete | |
: | |
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 WIP commit | |
commit=`git rev-list -n 1 --grep '^[from now]' "$range"` | |
if [ -n "$commit" ] | |
then | |
echo "Found [from now] in $local_ref, not pushing" | |
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