annotate modules/contrib/migrate_upgrade/.git/hooks/pre-push.sample @ 0:c75dbcec494b

Initial commit from drush-created site
author Chris Cannam
date Thu, 05 Jul 2018 14:24:15 +0000
parents
children
rev   line source
Chris@0 1 #!/bin/sh
Chris@0 2
Chris@0 3 # An example hook script to verify what is about to be pushed. Called by "git
Chris@0 4 # push" after it has checked the remote status, but before anything has been
Chris@0 5 # pushed. If this script exits with a non-zero status nothing will be pushed.
Chris@0 6 #
Chris@0 7 # This hook is called with the following parameters:
Chris@0 8 #
Chris@0 9 # $1 -- Name of the remote to which the push is being done
Chris@0 10 # $2 -- URL to which the push is being done
Chris@0 11 #
Chris@0 12 # If pushing without using a named remote those arguments will be equal.
Chris@0 13 #
Chris@0 14 # Information about the commits which are being pushed is supplied as lines to
Chris@0 15 # the standard input in the form:
Chris@0 16 #
Chris@0 17 # <local ref> <local sha1> <remote ref> <remote sha1>
Chris@0 18 #
Chris@0 19 # This sample shows how to prevent push of commits where the log message starts
Chris@0 20 # with "WIP" (work in progress).
Chris@0 21
Chris@0 22 remote="$1"
Chris@0 23 url="$2"
Chris@0 24
Chris@0 25 z40=0000000000000000000000000000000000000000
Chris@0 26
Chris@0 27 while read local_ref local_sha remote_ref remote_sha
Chris@0 28 do
Chris@0 29 if [ "$local_sha" = $z40 ]
Chris@0 30 then
Chris@0 31 # Handle delete
Chris@0 32 :
Chris@0 33 else
Chris@0 34 if [ "$remote_sha" = $z40 ]
Chris@0 35 then
Chris@0 36 # New branch, examine all commits
Chris@0 37 range="$local_sha"
Chris@0 38 else
Chris@0 39 # Update to existing branch, examine new commits
Chris@0 40 range="$remote_sha..$local_sha"
Chris@0 41 fi
Chris@0 42
Chris@0 43 # Check for WIP commit
Chris@0 44 commit=`git rev-list -n 1 --grep '^WIP' "$range"`
Chris@0 45 if [ -n "$commit" ]
Chris@0 46 then
Chris@0 47 echo >&2 "Found WIP commit in $local_ref, not pushing"
Chris@0 48 exit 1
Chris@0 49 fi
Chris@0 50 fi
Chris@0 51 done
Chris@0 52
Chris@0 53 exit 0