From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id OFlvNukK9mVD/wAAe85BDQ:P1 (envelope-from ) for ; Sat, 16 Mar 2024 22:11:06 +0100 Received: from aspmx1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id OFlvNukK9mVD/wAAe85BDQ (envelope-from ) for ; Sat, 16 Mar 2024 22:11:06 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=wolfsden.cz header.s=mail header.b=uL6G91lj; dkim=fail ("headers rsa verify failed") header.d=wolfsden.cz header.s=mail header.b=bXSjIAzW; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=wolfsden.cz (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1710623465; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:resent-cc:resent-from:resent-sender: resent-message-id:in-reply-to:in-reply-to:references:references: list-id:list-help:list-unsubscribe:list-subscribe:list-post: dkim-signature; bh=HFsEDXmppbA0lPOiRpt7X11oNQc5bnPxl/sz32Brgi4=; b=kz3/nkj/eFrHdPNP1sLhOXTEzffxCldLcifQPYeFyx/exVZlwkb2rcRCi9dpN9DEiKJ/A3 jcQd9lG7pfuuXX2WRl3QgXwtNKIkQf5Ii9asV7aVvPnASw4iIWZIXTze4JdK4Fn3XlFxsc sJxh9S5xQRPIL4GoxLpg3Q4FGJiBwQrqo1hwqTktSoKKskilMkDN20hbmSOwArizci0DqO LGY4Mn7HLxbzG0p0y2FRrz7bLrxSpq3PBwHjq/Y9i1nmt/VIBjHNkHwtX4BN+iihZZHWCI XckVO/YBYjLxS7UlQFp8xl6fbIwhBr8ph2YoivYzrMo2ZkARO2Q+U1LLTMDKbw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1710623465; a=rsa-sha256; cv=none; b=i55zCcsA+2ntwfjrl+1T7BXTlUvme0xNnNxuwRKODW1TytfVwdOdDw1lyAixs7OeeHNWlw Em/egbjWfCQwC6IWN2Ny9t9O+HkuQ3oY+lagFTB2OkokzY25CHF+f7hEkx41/JsyOlF87t Zm9MLJA88+6FXeBVjVu4/lc97yH9T4ggf1W+1xtLnrrWdn+DZQFJmmuxm5aMgy1GOXBS22 bhanyrz0b2Ojm+agGRnnJ6UtCem1hxu3hK4zBrdwZ0aum7KhRW8fPpj9eFNr1LxFpIvVyA wEdPr6S2tWPeVacsy5QQiCTbporKioTu4WGyOYcgx+9V+lCqJWzjMawr1FK4aQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=wolfsden.cz header.s=mail header.b=uL6G91lj; dkim=fail ("headers rsa verify failed") header.d=wolfsden.cz header.s=mail header.b=bXSjIAzW; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=wolfsden.cz (policy=none) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id A0A3C3DABD for ; Sat, 16 Mar 2024 22:11:05 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rlbIZ-0004Kh-Cg; Sat, 16 Mar 2024 17:10:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rlbIS-0004K0-Eu for guix-patches@gnu.org; Sat, 16 Mar 2024 17:10:30 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rlbIP-00006Y-Ho for guix-patches@gnu.org; Sat, 16 Mar 2024 17:10:28 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rlbJ0-00089I-Bd for guix-patches@gnu.org; Sat, 16 Mar 2024 17:11:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#69780] [PATCH 3/4] git authenticate: Install pre-push and post-checkout hooks. Resent-From: Tomas Volf <~@wolfsden.cz> Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 16 Mar 2024 21:11:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 69780 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 69780@debbugs.gnu.org Received: via spool by 69780-submit@debbugs.gnu.org id=B69780.171062340431249 (code B ref 69780); Sat, 16 Mar 2024 21:11:02 +0000 Received: (at 69780) by debbugs.gnu.org; 16 Mar 2024 21:10:04 +0000 Received: from localhost ([127.0.0.1]:57216 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rlbI4-00087x-9I for submit@debbugs.gnu.org; Sat, 16 Mar 2024 17:10:04 -0400 Received: from wolfsden.cz ([37.205.8.62]:36926) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <~@wolfsden.cz>) id 1rlbI1-00087S-Bt for 69780@debbugs.gnu.org; Sat, 16 Mar 2024 17:10:02 -0400 Received: by wolfsden.cz (Postfix, from userid 104) id 13F87290528; Sat, 16 Mar 2024 21:09:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=wolfsden.cz; s=mail; t=1710623363; bh=4DMKf3ngK7SrmcaZ8BWgZXygGaIJkM1b6NyWyU0MGnQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=uL6G91lj1lh29Xiomituby+uTaH9Ks6ACwDrcVrOVaAmzDwBJ/BzTG8s88YcmM0QB YXj0sOvbNj7HKw8yjNMOWI2s5R9UsQb25bbIOXI7XJ2FZjMQsCM6iqFHpkNXV9FBLc pa74tpKff9dRvJTqDPcecqFhnzcFHEiiQ6Sf7Rsfh4QRpMH3eRfx8a3+KzLN1US4iN SrHWdrzGEPaEt21cX4yEmtiZtoosx0TWRGoN610EYIkxiYqA8C+aCO1IwWQ7xglUkY Qq1xJ5iUlMJ4YMi9WZ9sEay8qrXRsAE69hUqO3uk+8imBRQuz+BqDEpv6WPMp4tIAN EI8avSHJuxB1VbRIbmiLcb24VdmOZfzgt3mbA9QUb01jfDfWGU+786U6MDo3nJ7d0y QuLS820dVvQeFqXEhlw2JFcMi2KuLf0BYaA5376/FFEF0mtNU91TKQQnigln+QAQum 1ArEZG8S7sRpl2KmNihXMyqsbe736UHAFtn4c3gD14yKnU/5WYtaLqFkK276MvH/rB wbCgbhp4M8VG5Wx5GqV8rR2LBUoJ/uEN7VCSwbqGAayv4tbAC42tm9anMItGRKxd2t gDrmLsrK7k6nI6LCnRRQiitZLEHBPEYsAoAgLVwk2J0MUfnSYHtft/7AAarArvlWgh PjdocLvT4639NloYxCsz33N8= Received: from localhost (unknown [146.70.134.188]) by wolfsden.cz (Postfix) with ESMTPSA id E0A7A291094; Sat, 16 Mar 2024 21:09:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=wolfsden.cz; s=mail; t=1710623362; bh=4DMKf3ngK7SrmcaZ8BWgZXygGaIJkM1b6NyWyU0MGnQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=bXSjIAzWGnKsyGmvwLR8p6hBeefjWAOp1AYsd1ws5MucC/umt8nlCXYppcwOrZRHa RV3K60LcbD42VSiooy0S3+2WG2/iwGwZTjfr+HLSSwT/ui6Efu6O5gVK8r2Z7lQ81s FZwhoDb6drHk52LayKGsr4AACVrvnKen/BXmFNSq10YF+a3x16qlScR1uTqc4KIQl0 G2dwFBjUi7lsTDgRWhJzb6iM8oUTcR0yKiLvmNZZ8VBj3dmxX25bmcdzFpx+KmBCrr HlfQhUtxgP4DfsU+noAbC2iyo1IG158DlMVTxgs14ANPUHkX/xOnyRUwjm0uK3lMrl SZDybHZ0gVPuhUv3oRz8mqd1b7GT87a3joYJvICbdz6WQTPnMBECHK4/Sw4qvGafqJ VdnlVguLh6KKQFd7+G7zenz02XA6B2KyUQO3ZgJ9bfnFBKDhztvDO7zimJIOQ9A6Rm GD7u6nVr82PbqcArlTg5I9kjvbrJHQUhXK+kaCQIyNmMBE29dOvuw375S9+9i5eFwq 7OxK9oHub4R/xJwukorEJwF8aSLH77xSubAVv4DlhcIJyvP4le3gdKkmuNPr4ZKUWV R8yuHETXnb5umWiNE+Kl2BMlGgfDBRr+ot0mgWY9BXtKP5EjIbA3BcKKknh1wMs9De Q+1Y6oOhmCiNIcmVW5swX6SU= Date: Sat, 16 Mar 2024 22:09:20 +0100 From: Tomas Volf <~@wolfsden.cz> Message-ID: References: <6a556beb2566aa401d5064049e136ff2a7669b63.1710351278.git.ludo@gnu.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="qM+sevcVU42crcO3" Content-Disposition: inline In-Reply-To: <6a556beb2566aa401d5064049e136ff2a7669b63.1710351278.git.ludo@gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Spam-Score: -6.80 X-Spam-Score: -6.80 X-Migadu-Queue-Id: A0A3C3DABD X-Migadu-Scanner: mx11.migadu.com X-TUID: 6Y/Hp2Av6kDe --qM+sevcVU42crcO3 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2024-03-13 18:42:21 +0100, Ludovic Court=E8s wrote: > * guix/scripts/git/authenticate.scm (install-hooks): New procedure. > (guix-git-authenticate): Use it. > * doc/guix.texi (Invoking guix git authenticate): Document it. > > Change-Id: I4464a33193186e85b476a12740e54412bd58429c > --- > doc/guix.texi | 5 ++++ > guix/scripts/git/authenticate.scm | 43 ++++++++++++++++++++++++++++++- > 2 files changed, 47 insertions(+), 1 deletion(-) > > diff --git a/doc/guix.texi b/doc/guix.texi > index ac0766b98c..b1672803c0 100644 > --- a/doc/guix.texi > +++ b/doc/guix.texi > @@ -7624,6 +7624,11 @@ Invoking guix git authenticate > guix git authenticate [@var{options}@dots{}] > @end example > > +The first run also attempts to install pre-push and post-checkout hooks, > +such that @command{guix git authenticate} is invoked as soon as you run > +@command{git push}, @command{git checkout}, and related commands; it > +does not overwrite preexisting hooks though. > + > The options below allow you to fine-tune the process. > > @table @code > diff --git a/guix/scripts/git/authenticate.scm b/guix/scripts/git/authent= icate.scm > index 36e1aa6228..13e1de3099 100644 > --- a/guix/scripts/git/authenticate.scm > +++ b/guix/scripts/git/authenticate.scm > @@ -129,6 +129,46 @@ (define* (record-configuration repository > (info (G_ "introduction and keyring configuration recorded in '~a'~%") > config-file)) > > +(define (install-hooks repository) > + "Attempt to install in REPOSITORY pre-push and update hooks that invoke > +'guix git authenticate'. Bail out if one of these already exists." > + (define directory > + (repository-directory repository)) > + > + (define pre-push-hook > + (in-vicinity directory "hooks/pre-push")) > + > + (define post-checkout-hook > + (in-vicinity directory "hooks/post-checkout")) I think these will not work with worktrees. > + > + (if (or (file-exists? pre-push-hook) > + (file-exists? post-checkout-hook)) > + (begin > + (warning (G_ "not overriding pre-existing hooks '~a' and '~a'~%") > + pre-push-hook post-checkout-hook) > + (display-hint (G_ "Consider running @command{guix git authentica= te} > +from your pre-push and update hooks so your repository is automatically > +authenticated before you push or receive updates."))) > + (begin > + (call-with-output-file pre-push-hook > + (lambda (port) > + (format port "#!/bin/sh > +set -e > +while read local_ref local_oid remote_ref remote_oid > +do > + guix git authenticate --end=3D\"$local_ref\" Am I right in believing that the --end does solve #69541? Shame it (--end)= is not documented in the --help. > +done\n") > + (chmod port #o755))) What is role of etc/git/pre-push now? Should it be removed? Should it be updated to run this code instead? > + (call-with-output-file post-checkout-hook > + (lambda (port) > + (format port "#!/bin/sh > +oldrev=3D\"$1\" > +newrev=3D\"$2\" > +exec guix git authenticate --end=3D\"$newrev\"\n") > + (chmod port #o755))) > + (info (G_ "installed hooks '~a' and '~a'~%") > + pre-push-hook post-checkout-hook)))) > + > (define (show-stats stats) > "Display STATS, an alist containing commit signing stats as returned by > 'authenticate-repository'." > @@ -250,7 +290,8 @@ (define (guix-git-authenticate . args) > (unless (configured? repository) > (record-configuration repository > #:commit commit #:signer signer > - #:keyring-reference keyring)) > + #:keyring-reference keyring) > + (install-hooks repository)) > > (when (and show-stats? (not (null? stats))) > (show-stats stats)))))) > -- > 2.41.0 > > > > Have a nice day, Tomas Volf -- There are only two hard things in Computer Science: cache invalidation, naming things and off-by-one errors. --qM+sevcVU42crcO3 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEt4NJs4wUfTYpiGikL7/ufbZ/wakFAmX2CoAACgkQL7/ufbZ/ waksVBAAopZKVDHb6En2Zy86WkS4z0MIm3nf68OmSP1zaFrbw52+R3jrgo6kHMAh QK6VTZUi7jc7uuZ8THs509Yt+ceTlYk0IYeIuXT2u38MiKpdeC5Od2yIjYKvF7KQ qnIFPnKOsGGhSWd7Lic7JtiyfVGV79ZgOIFBgDsHyAN49D/3ATiY7e0GitVMTTE4 7tpQKimui0TtK2nT+E+r8uvHSuPSoxsi8ebBsBu+RcYyAyonST3Qm5rcTuZTtkoy GN2n3Pig72RMC6INNtOYOMaPlHQTPw1dvsRR2rQUD1DF9uDo0WL3DjINui5qUVw8 /w5eXc6r//kDIM8hbEeHQ73rI6/lnspPN0Aux/Q7/ck0QYkzfCD6UYMASMAQn/CK FWGFFGPGYkad+a1B7t9MYbrR4L5OAvADdjG9w0hp/YCoGb29YjoehDbYQr8Om6gt fT8bXQSOTBVLa76shVmhVFdDwT2P2DcmDfpFvzi1218lMlnxKFQ8vCerGWU+aQdT 62dimdGHIzNXsobLWANuuVKUqmX+Zw3OzQsDs9sNxy10h+5AxC/ax/J4kILl0fLz SRUFpEokN2PtEP0NqFEiQ7ejHtUPIFIFf7nlT/BpTQIYpRIQ6iFOGL5PpxdAZMYB BKzecBZcXn+xi0IHvQwf6MSiB25TpPv/L+XuOResZDSkS2LNG9k= =zj28 -----END PGP SIGNATURE----- --qM+sevcVU42crcO3--