[PATCH] maint: Only run `make authenticate` when pushing commits.

  • Done
  • quality assurance status badge
Details
3 participants
  • Jakub K?dzio?ka
  • Leo Famulari
  • Ludovic Courtès
Owner
unassigned
Submitted by
Leo Famulari
Severity
normal
L
L
Leo Famulari wrote on 14 Aug 2020 22:30
(address . guix-patches@gnu.org)
12ad49f9266b146b81f7c7347ec4d62d18602039.1597437024.git.leo@famulari.name
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.
---
etc/git/pre-push | 28 ++++++++++++++++++----------
1 file changed, 18 insertions(+), 10 deletions(-)

Toggle diff (38 lines)
diff --git a/etc/git/pre-push b/etc/git/pre-push
index 415345fc75..689673dcc9 100755
--- a/etc/git/pre-push
+++ b/etc/git/pre-push
@@ -20,13 +20,21 @@
#
# <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
+z40=0000000000000000000000000000000000000000
+
+# If deleting a branch, there are no commits to check.
+if [ "$local_sha" = $z40 ]
+then
+ true
+else
+ # 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
--
2.28.0
J
J
Jakub K?dzio?ka wrote on 20 Aug 2020 00:29
(name . Leo Famulari)(address . leo@famulari.name)(address . guix-patches@gnu.org)
20200819222927.l5hcfqrjvenpufhy@gravity
On Fri, Aug 14, 2020 at 04:30:47PM -0400, Leo Famulari wrote:
Toggle quote (8 lines)
> +z40=0000000000000000000000000000000000000000
> +
> +# If deleting a branch, there are no commits to check.
> +if [ "$local_sha" = $z40 ]
> +then
> + true
> +else

Is there a reason this `if' is written like that? I would use != and get
rid of the do-nothing branch entirely.

Regards,
Jakub K?dzio?ka
-----BEGIN PGP SIGNATURE-----

iQIzBAABCAAdFiEE5Xa/ss9usT31cTO54xWnWEYTFWQFAl89p8cACgkQ4xWnWEYT
FWTAhhAAsEnqBYe0l51UZmujyo1JyAKwVkBA+t6Soh/FOeFnm138vGADoEKKPKmY
r9jyiIcIcFSK9Bb/sFc3JpMEqgshURnpgXVMybCWavoH1CmoDttNtAniEmoP0SDS
fK9xMiDC0RTgqpNHMNRx+H+jWBMT75dbtu+Bb1drOcIwySbOAwbQeZ0LH1rm2/pA
7hbxMGaNYvbwMuh9EjeqmmqyiMYUQuccY9b0TJ0bfdNUzHynvrFm/cG8+Bpfiy64
qQtoMb7cY8/pzRrwQoiZoqK9WKShs2BXHb8E78STVHrQvUOSmAMrjHnIxtsODINo
eYVC34BTItbNpTGECq9HTv0P3GLzAky5uDa8fiUuqAi8yH8R+uEZoA+2i8rTjVuP
DUZaf7DHXdrNUIJVarx3aOp4Um120uFlvV1gLSECVEmXTNrqafiXFASMJNN6H/kh
PfgogJylZggBOBGQ+dmpKIoaFXsyaHExOiqnd38uS+3vEXzM0Vjn1kCOXH5bKSYl
tyr8zOvCEyoBfb7HMYplxY4Nlt6iqWwNLkJj6QtzR5/bw7XTDHvU/Nmjo1XjyZKC
nYIMv82KPnHUyYU2qBnj21JSMakgv7MzvNRH7gRz4zaFM1cHQurrFFSNu6tL/hRY
NdybCnCaew+Vj42v4gxYWVFBwHUCJ155k9/OKSMFps4LMFeGGpw=
=SGHl
-----END PGP SIGNATURE-----


L
L
Ludovic Courtès wrote on 30 Aug 2020 21:47
Re: [bug#42868] [PATCH] maint: Only run `make authenticate` when pushing commits.
(name . Leo Famulari)(address . leo@famulari.name)(address . 42868@debbugs.gnu.org)
873643j4pc.fsf@gnu.org
Hi,

Leo Famulari <leo@famulari.name> skribis:

Toggle quote (5 lines)
> 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.

Thanks!

Ludo’.
L
L
Leo Famulari wrote on 13 Dec 2020 21:35
(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 42868@debbugs.gnu.org)
X9Z7DG6rdifUz/Nm@jasmine.lan
On Sun, Aug 30, 2020 at 09:47:59PM +0200, Ludovic Courtès wrote:
Toggle quote (11 lines)
> 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(-)

Toggle diff (43 lines)
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
--
2.29.2
-----BEGIN PGP SIGNATURE-----

iQIzBAABCAAdFiEEsFFZSPHn08G5gDigJkb6MLrKfwgFAl/WewwACgkQJkb6MLrK
fwgBfQ//Qri2GagSN+5KFYHZa4mRf8yMhAw81+t6/0HMBaOcWNPpmzpGuxNykN11
LJFiOaRL2AgXS72D8/VGoWmpqIlzHsoF4Rx2v+JqVSJ83tWfyPNpM6+lB48+gBB7
TLcYCASlqzAH0VBm49uA51GenC3KPray66v4tAhJl/YMcCP+Dde43lqFnAUv8Y8q
+xn83krNMOBjYuVRIL34A1xbSSW7x2eTcvgnlIQ/bGovb6vbbfphVwUzGNOzNYw1
4+tVRXhIWs1ncRj4NliuuTpoSzk7PVaGfhu7wpq2SOQMb/5pyI3dV4RamlHafSK1
tuUt4JhI2uA/SJ1fnlRw+xjxEK2Cp/3RdfKwros4EMfVaHSLIYJE9pN25/E8eeO2
v/lGC+K3PxxLxl+7lwNXvbGEsFqZy1hfjOs951Es9yNuGk6kQ02rKK7XtCWvYA2c
AFv+VHECZw+X7nnk9SRQ+p4pVaRgDd83/f8nbUvf9CvoDQmkbsTwhOyNeCbRVVQo
byECaxduVgI7Sr0eNRIRHvmhGWlLD4N3hLSYLom+Z0+57hRmXKnkYjN5Eb/9LGpN
KazQE0HbvQkwURqdeMEIMXlxaMKUX1DtKiuwHak3Iy8yD3mzEUtMyrsP7tgSuPAb
tSlSRe8cyVsBiUzVzEYcxnbU6mYq6KTowgNFGxvfxcnmSQD0GJw=
=+FVi
-----END PGP SIGNATURE-----


L
L
Ludovic Courtès wrote on 14 Dec 2020 09:28
(name . Leo Famulari)(address . leo@famulari.name)(address . 42868@debbugs.gnu.org)
87a6ugyepa.fsf@gnu.org
Hi,

Leo Famulari <leo@famulari.name> skribis:

Toggle quote (7 lines)
> 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’.
L
L
Leo Famulari wrote on 14 Dec 2020 18:17
(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 42868-done@debbugs.gnu.org)
X9eeGfXE6kmXSCb8@jasmine.lan
On Mon, Dec 14, 2020 at 09:28:01AM +0100, Ludovic Court�s wrote:
Toggle quote (13 lines)
> 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
Closed
?