git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
b3bc5276bf305932b4ce3acdcd8693d4b76565b1 blob 1359 bytes (raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
 
#!/bin/sh

# An example hook script to verify what is about to be pushed.  Called by "git
# push" after it has checked the remote status, but before anything has been
# pushed.  If this script exits with a non-zero status nothing will be pushed.
#
# This hook is called with the following parameters:
#
# $1 -- Name of the remote to which the push is being done
# $2 -- URL to which the push is being done
#
# If pushing without using a named remote those arguments will be equal.
#
# Information about the commits which are being pushed is supplied as lines to
# the standard input in the form:
#
#   <local ref> <local sha1> <remote ref> <remote sha1>
#
# This sample shows how to prevent push of commits where the log message starts
# with "WIP" (work in progress).

remote="$1"
url="$2"

null_oid="$(git rev-parse --null-oid)"

while read local_ref local_sha remote_ref remote_sha
do
	if [ "$local_sha" = "$null_oid" ]
	then
		# Handle delete
		:
	else
		if [ "$remote_sha" = "$null_oid" ]
		then
			# New branch, examine all commits
			range="$local_sha"
		else
			# Update to existing branch, examine new commits
			range="$remote_sha..$local_sha"
		fi

		# Check for WIP commit
		commit="$(git rev-list -n 1 --grep '^WIP' "$range")"
		if [ -n "$commit" ]
		then
			echo >&2 "Found WIP commit in $local_ref, not pushing"
			exit 1
		fi
	fi
done

exit 0
debug log:

solving b3bc5276bf ...
found b3bc5276bf in https://public-inbox.org/git/9d6c2951ab0a2c2e92353c238b008538fe6a6327.1600427894.git.liu.denton@gmail.com/
found 64b5707553 in https://public-inbox.org/git/ed1ade73281bb78ab3a1d4fd1291a951ca52f0b4.1600427894.git.liu.denton@gmail.com/
found 6187dbf439 in git.git.git
preparing index
index prepared:
100755 6187dbf4390fc6e28445dd3d988aefb9d1111988	templates/hooks--pre-push.sample

applying [1/2] https://public-inbox.org/git/ed1ade73281bb78ab3a1d4fd1291a951ca52f0b4.1600427894.git.liu.denton@gmail.com/
diff --git a/templates/hooks--pre-push.sample b/templates/hooks--pre-push.sample
index 6187dbf439..64b5707553 100755


applying [2/2] https://public-inbox.org/git/9d6c2951ab0a2c2e92353c238b008538fe6a6327.1600427894.git.liu.denton@gmail.com/
diff --git a/templates/hooks--pre-push.sample b/templates/hooks--pre-push.sample
index 64b5707553..b3bc5276bf 100755

Checking patch templates/hooks--pre-push.sample...
Applied patch templates/hooks--pre-push.sample cleanly.
Checking patch templates/hooks--pre-push.sample...
Applied patch templates/hooks--pre-push.sample cleanly.

index at:
100755 b3bc5276bf305932b4ce3acdcd8693d4b76565b1	templates/hooks--pre-push.sample

Code repositories for project(s) associated with this inbox:

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).