annotate vendor/drupal/coder/.git/hooks/pre-push.sample @ 19:fa3358dc1485 tip

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