All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Sebastian Götte" <jaseg@physik.tu-berlin.de>
To: gitster@pobox.com
Cc: git@vger.kernel.org, joel@trustly.com, git@drmicha.warpmail.net
Subject: [PATCH v2 1/1] templates: pre-push hook: check for missing GPG signatures
Date: Thu, 25 Apr 2013 14:19:16 +0200	[thread overview]
Message-ID: <51791F44.9090406@physik.tu-berlin.de> (raw)
In-Reply-To: <cover.1366890748.git.jaseg@physik-pool.tu-berlin.de>

Also added a missing colon that caused my bash 4.2.45(2)-release to
complain about an empty if.

Signed-off-by: Sebastian Götte <jaseg@physik-pool.tu-berlin.de>
---
 templates/hooks--pre-push.sample | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/templates/hooks--pre-push.sample b/templates/hooks--pre-push.sample
old mode 100644
new mode 100755
index 15ab6d8..a16283c
--- a/templates/hooks--pre-push.sample
+++ b/templates/hooks--pre-push.sample
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-# An example hook script to verify what is about to be pushed.  Called by "git
+# 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.
 #
@@ -14,22 +14,22 @@
 # 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>
+#	<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).
+# This sample shows how to prevent pushing commits without good GPG signatures
+# or where the log message starts with "WIP" (work in progress).
 
 remote="$1"
 url="$2"
 
 z40=0000000000000000000000000000000000000000
+exitcode=0
 
-IFS=' '
 while read local_ref local_sha remote_ref remote_sha
 do
 	if [ "$local_sha" = $z40 ]
 	then
-		# Handle delete
+		: # Handle delete
 	else
 		if [ "$remote_sha" = $z40 ]
 		then
@@ -45,9 +45,16 @@ do
 		if [ -n "$commit" ]
 		then
 			echo "Found WIP commit in $local_ref, not pushing"
-			exit 1
+			exitcode=1
 		fi
+
+		# Check for missing good GPG signatures
+		for commit in `git log --format="%G? %h" "$range" | grep -v '^G' | cut -d\  -f2`
+		do
+			echo "Commit $commit does not have a good GPG signature"
+			exitcode=1
+		done
 	fi
 done
 
-exit 0
+exit $exitcode
-- 
1.8.2

  parent reply	other threads:[~2013-04-25 12:19 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CAASwCXf3YHmdQ_eSkShyzn5VniO=ufm3VTqV1JVOUN610bzE_A@mail.gmail.com>
2013-04-22 23:43 ` [PATCH] Add .gitconfig variable commit.gpg-sign Junio C Hamano
2013-04-23  0:00   ` Joel Jacobson
2013-04-23 11:37     ` Michael J Gruber
2013-04-23 17:53       ` Junio C Hamano
2013-04-23 17:58         ` Joel Jacobson
2013-04-23 19:25           ` Junio C Hamano
2013-04-23 19:56             ` Joel Jacobson
2013-04-24  8:53               ` Sebastian Götte
2013-04-24  9:51                 ` Michael J Gruber
2013-04-24 17:30                   ` [PATCH 1/1] templates: pre-push hook: check for missing GPG signatures (was: Re: [PATCH] Add .gitconfig variable commit.gpg-sign) Sebastian Götte
2013-04-24 19:54                     ` [PATCH 1/1] templates: pre-push hook: check for missing GPG signatures Junio C Hamano
2013-04-25 12:19                       ` [PATCH v2 0/1] " Sebastian Götte
2013-04-25 16:50                         ` Junio C Hamano
     [not found]                       ` <cover.1366890748.git.jaseg@physik-pool.tu-berlin.de>
2013-04-25 12:19                         ` Sebastian Götte [this message]
2013-04-23 14:01   ` [PATCH] Add .gitconfig variable commit.gpg-sign Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=51791F44.9090406@physik.tu-berlin.de \
    --to=jaseg@physik.tu-berlin.de \
    --cc=git@drmicha.warpmail.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=joel@trustly.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.