annotate BSseeker2/.git/hooks/pre-push.sample @ 1:8b26adf64adc draft default tip

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