annotate myTools/.git/hooks/pre-push.sample @ 6:f9f71cf4c3e3

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