Chris@0: #!/bin/sh Chris@0: Chris@0: # An example hook script to verify what is about to be pushed. Called by "git Chris@0: # push" after it has checked the remote status, but before anything has been Chris@0: # pushed. If this script exits with a non-zero status nothing will be pushed. Chris@0: # Chris@0: # This hook is called with the following parameters: Chris@0: # Chris@0: # $1 -- Name of the remote to which the push is being done Chris@0: # $2 -- URL to which the push is being done Chris@0: # Chris@0: # If pushing without using a named remote those arguments will be equal. Chris@0: # Chris@0: # Information about the commits which are being pushed is supplied as lines to Chris@0: # the standard input in the form: Chris@0: # Chris@0: # Chris@0: # Chris@0: # This sample shows how to prevent push of commits where the log message starts Chris@0: # with "WIP" (work in progress). Chris@0: Chris@0: remote="$1" Chris@0: url="$2" Chris@0: Chris@0: z40=0000000000000000000000000000000000000000 Chris@0: Chris@0: while read local_ref local_sha remote_ref remote_sha Chris@0: do Chris@0: if [ "$local_sha" = $z40 ] Chris@0: then Chris@0: # Handle delete Chris@0: : Chris@0: else Chris@0: if [ "$remote_sha" = $z40 ] Chris@0: then Chris@0: # New branch, examine all commits Chris@0: range="$local_sha" Chris@0: else Chris@0: # Update to existing branch, examine new commits Chris@0: range="$remote_sha..$local_sha" Chris@0: fi Chris@0: Chris@0: # Check for WIP commit Chris@0: commit=`git rev-list -n 1 --grep '^WIP' "$range"` Chris@0: if [ -n "$commit" ] Chris@0: then Chris@0: echo >&2 "Found WIP commit in $local_ref, not pushing" Chris@0: exit 1 Chris@0: fi Chris@0: fi Chris@0: done Chris@0: Chris@0: exit 0