diff mbox series

[bug#42868] maint: Only run `make authenticate` when pushing commits.

Message ID X9Z7DG6rdifUz/Nm@jasmine.lan
State Accepted
Headers show
Series [bug#42868] maint: Only run `make authenticate` when pushing commits. | expand

Checks

Context Check Description
cbaines/submitting builds success
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch fail View Laminar job
cbaines/issue success View issue

Commit Message

Leo Famulari Dec. 13, 2020, 8:35 p.m. UTC
On Sun, Aug 30, 2020 at 09:47:59PM +0200, Ludovic Courtès wrote:
> Hi,
> 
> Leo Famulari <leo@famulari.name> skribis:
> 
> > When deleting a remote branch, no commits are pushed to the remote, and
> > thus there are no signatures to be verified.
> >
> > * etc/git/pre-push: Exit early when deleting a branch.
> 
> I agree with Jakub regarding the ‘if’ :-), but other than that it LGTM.

The previous version of this patch was untested and broken!

Here is a new one that is actually tested and working.
From e8546a590a560825c3231af14724329c3d2bfee7 Mon Sep 17 00:00:00 2001
From: Leo Famulari <leo@famulari.name>
Date: Fri, 14 Aug 2020 16:30:47 -0400
Subject: [PATCH] maint: Only run `make authenticate` when pushing commits.

* etc/git/pre-push: Exit early when deleting a branch.
---
 etc/git/pre-push | 33 +++++++++++++++++++++++----------
 1 file changed, 23 insertions(+), 10 deletions(-)

Comments

Ludovic Courtès Dec. 14, 2020, 8:28 a.m. UTC | #1
Hi,

Leo Famulari <leo@famulari.name> skribis:

> From e8546a590a560825c3231af14724329c3d2bfee7 Mon Sep 17 00:00:00 2001
> From: Leo Famulari <leo@famulari.name>
> Date: Fri, 14 Aug 2020 16:30:47 -0400
> Subject: [PATCH] maint: Only run `make authenticate` when pushing commits.
>
> * etc/git/pre-push: Exit early when deleting a branch.

LGTM, thanks!

Ludo’.
Leo Famulari Dec. 14, 2020, 5:17 p.m. UTC | #2
On Mon, Dec 14, 2020 at 09:28:01AM +0100, Ludovic Courtès wrote:
> Hi,
> 
> Leo Famulari <leo@famulari.name> skribis:
> 
> > From e8546a590a560825c3231af14724329c3d2bfee7 Mon Sep 17 00:00:00 2001
> > From: Leo Famulari <leo@famulari.name>
> > Date: Fri, 14 Aug 2020 16:30:47 -0400
> > Subject: [PATCH] maint: Only run `make authenticate` when pushing commits.
> >
> > * etc/git/pre-push: Exit early when deleting a branch.
> 
> LGTM, thanks!

Thanks! Pushed as 80ebcdd100a82fdc582e62f35042c74ce38ea753
diff mbox series

Patch

diff --git a/etc/git/pre-push b/etc/git/pre-push
index 415345fc75..59671b0d58 100755
--- a/etc/git/pre-push
+++ b/etc/git/pre-push
@@ -20,13 +20,26 @@ 
 #
 #   <local ref> <local sha1> <remote ref> <remote sha1>
 
-# Only use the hook when pushing to Savannah.
-case "$2" in
-    *.gnu.org*)
-	exec make authenticate check-channel-news
-	exit 127
-	;;
-    *)
-	exit 0
-	;;
-esac
+# This is the "empty hash" used by Git when pushing a branch deletion.
+z40=0000000000000000000000000000000000000000
+
+while read local_ref local_hash remote_ref remote_hash
+do
+	# When deleting a remote branch, no commits are pushed to the remote, and
+	# thus there are no signatures to be verified.
+	if [ "$local_hash" != $z40 ]
+	then
+		# Only use the hook when pushing to Savannah.
+		case "$2" in
+		    *.gnu.org*)
+			exec make authenticate check-channel-news
+			exit 127
+			;;
+		    *)
+			exit 0
+			;;
+		esac
+	fi
+done
+
+exit 0