unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Leo Famulari <leo@famulari.name>
To: "Ludovic Courtès" <ludo@gnu.org>
Cc: guix-devel@gnu.org
Subject: Re: pre-push signature hook error reporting
Date: Mon, 6 Feb 2017 16:39:22 +0100	[thread overview]
Message-ID: <20170206153922.GA10240@jasmine> (raw)
In-Reply-To: <20170121013910.GC26714@jasmine>


[-- Attachment #1.1: Type: text/plain, Size: 478 bytes --]

On Fri, Jan 20, 2017 at 03:05:42PM +0100, Ludovic Courtès wrote:
> For the pre-push hook, the overhead seems reasonable (perhaps we could
> limit the range to commits after the first signed commit to avoid
> looping for no reason?) and an improvement.

Here is a patch for the hook that I've been using for the past couple weeks.

For the common use case of pushing new commits to an existing branch, I
don't notice the hook at all, except when it catches my mistakes.

[-- Attachment #1.2: 0001-etc-The-pre-push-hook-says-which-commits-failed-the-.patch --]
[-- Type: text/plain, Size: 1610 bytes --]

From 7d8206949f98a121bb2d50e0eecfcba1d9cce27a Mon Sep 17 00:00:00 2001
From: Leo Famulari <leo@famulari.name>
Date: Mon, 23 Jan 2017 00:57:46 -0500
Subject: [PATCH] etc: The pre-push hook says which commits failed the
 signature check.

* etc/git/pre-push: Check each commit's signature individually so that
we can report which commits fail the check.
---
 etc/git/pre-push | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/etc/git/pre-push b/etc/git/pre-push
index c894c5a9e..9206a2dfe 100755
--- a/etc/git/pre-push
+++ b/etc/git/pre-push
@@ -40,17 +40,29 @@ do
 	else
 		if [ "$remote_sha" = $z40 ]
 		then
-			# New branch, examine all commits
-			range="$local_sha"
+			# We are pushing a new branch. To prevent wasting too
+			# much time for this relatively rare case, we examine
+			# all commits since the first signed commit, rather than
+			# the full history. This check *will* fail, and the user
+			# will need to temporarily disable the hook to push the
+			# new branch.
+			range="e3d0fcbf7e55e8cbe8d0a1c5a24d73f341d7243b..$local_sha"
 		else
 			# Update to existing branch, examine new commits
 			range="$remote_sha..$local_sha"
 		fi
 
 		# Verify the signatures of all commits being pushed.
-		git verify-commit $(git rev-list $range) >/dev/null 2>&1
-
-		exit $?
+		ret=0
+		for commit in $(git rev-list $range)
+		do
+			if ! git verify-commit $commit >/dev/null 2>&1
+			then
+				printf "%s failed signature check\n" $commit
+				ret=1
+			fi
+		done
+		exit $ret
 	fi
 done
 
-- 
2.11.0


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2017-02-06 15:39 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-05 16:14 [PATCH v6] gnu: python-sphinx: Update to 1.4.8 Danny Milosavljevic
2017-01-05 16:40 ` Marius Bakke
     [not found]   ` <8760lj5eb6.fsf@kirby.i-did-not-set--mail-host-address--so-tickle-me>
     [not found]     ` <20170113152400.GA24322@jasmine>
2017-01-17  3:14       ` pre-push signature hook error reporting [was Re: [PATCH v6] gnu: python-sphinx: Update to 1.4.8.] Leo Famulari
2017-01-17 11:34         ` Danny Milosavljevic
2017-01-17 12:56           ` Hartmut Goebel
2017-01-17 19:44             ` Leo Famulari
2017-01-17 19:38           ` Leo Famulari
2017-01-17 14:55         ` Hartmut Goebel
2017-01-17 19:39           ` Leo Famulari
2017-01-20 14:05         ` Ludovic Courtès
2017-01-21  1:39           ` Leo Famulari
2017-02-06 15:39             ` Leo Famulari [this message]
2017-02-06 16:37               ` pre-push signature hook error reporting Marius Bakke
2017-02-07 13:15                 ` Ludovic Courtès

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

  List information: https://guix.gnu.org/

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

  git send-email \
    --in-reply-to=20170206153922.GA10240@jasmine \
    --to=leo@famulari.name \
    --cc=guix-devel@gnu.org \
    --cc=ludo@gnu.org \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.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).