annotate glang-galaxy-conf/.git/hooks/pre-push.sample @ 2:8947fca5f715 draft default tip

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