Skip to content

Instantly share code, notes, and snippets.

@kazu634
Created January 5, 2014 11:48
Show Gist options
  • Save kazu634/8267388 to your computer and use it in GitHub Desktop.
Save kazu634/8267388 to your computer and use it in GitHub Desktop.
Gitのpre-push hook用スクリプト。git-nowコマンドと一緒に使うことを想定しています。
#!/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