GNU logs - #66961, boring messages


Message sent to guix@HIDDEN, dev@HIDDEN, ludo@HIDDEN, othacehe@HIDDEN, rekado@HIDDEN, zimon.toutoune@HIDDEN, me@HIDDEN, guix-patches@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: [bug#66961] [PATCH] scripts: hash: Handle repository with different VCS folders.
Resent-From: Simon Tournier <zimon.toutoune@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: guix@HIDDEN, dev@HIDDEN, ludo@HIDDEN, othacehe@HIDDEN, rekado@HIDDEN, zimon.toutoune@HIDDEN, me@HIDDEN, guix-patches@HIDDEN
Resent-Date: Sun, 05 Nov 2023 23:02:01 +0000
Resent-Message-ID: <handler.66961.B.169922531526446 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: report 66961
X-GNU-PR-Package: guix-patches
X-GNU-PR-Keywords: patch
To: 66961 <at> debbugs.gnu.org
Cc: Simon Tournier <zimon.toutoune@HIDDEN>, Christopher Baines <guix@HIDDEN>, Josselin Poiret <dev@HIDDEN>, Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Ricardo Wurmus <rekado@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN>
X-Debbugs-Original-To: guix-patches@HIDDEN
X-Debbugs-Original-Xcc: Christopher Baines <guix@HIDDEN>, Josselin Poiret <dev@HIDDEN>, Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Ricardo Wurmus <rekado@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN>
Received: via spool by submit <at> debbugs.gnu.org id=B.169922531526446
          (code B ref -1); Sun, 05 Nov 2023 23:02:01 +0000
Received: (at submit) by debbugs.gnu.org; 5 Nov 2023 23:01:55 +0000
Received: from localhost ([127.0.0.1]:38338 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qzm7u-0006sS-U5
	for submit <at> debbugs.gnu.org; Sun, 05 Nov 2023 18:01:55 -0500
Received: from lists.gnu.org ([2001:470:142::17]:45354)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <zimon.toutoune@HIDDEN>) id 1qzm7r-0006sE-Vn
 for submit <at> debbugs.gnu.org; Sun, 05 Nov 2023 18:01:53 -0500
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 <zimon.toutoune@HIDDEN>)
 id 1qzm7B-00061I-G5
 for guix-patches@HIDDEN; Sun, 05 Nov 2023 18:01:09 -0500
Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <zimon.toutoune@HIDDEN>)
 id 1qzm79-0005vp-0c
 for guix-patches@HIDDEN; Sun, 05 Nov 2023 18:01:09 -0500
Received: by mail-wm1-x330.google.com with SMTP id
 5b1f17b1804b1-408fd07bb78so4976355e9.1
 for <guix-patches@HIDDEN>; Sun, 05 Nov 2023 15:01:06 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1699225265; x=1699830065; darn=gnu.org;
 h=content-transfer-encoding:mime-version:message-id:date:subject:cc
 :to:from:from:to:cc:subject:date:message-id:reply-to;
 bh=pLqWwnXmtS1revD+osuVniPpZQCkZqNiibmgdQ7aHK4=;
 b=KUe7sf2tPZPjiLT1CJ6ALjfw0AmX7NZDxBlTgQcwDqGEonbkatPpoL8vL7VKgcibZb
 NWbn8tVqjHpuWtbV+lcyGyLosaPfFCw1FsPlupCKypyr5hbPMxDQWctcvGi55+gfFQu8
 dDGciqbfoJ7cFFw7cM9AYLO21JoUc9v4KOm2g/z8mDqr3LBYdIDOk2hc+1+7lhZi9oOV
 Hrn2CqHYdSgjZx9nBjv0IVNo7kU2kBr2hPFzg9+DohXdMOSj8Mk+Wg+ieX00YjKLULCW
 /L64yL9b5jNRUOusBQslk5mDplMgRuZu95Ym4S0Ky5IiDSWsREtgq+Q0kapzJNk+Edwk
 5HRA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1699225265; x=1699830065;
 h=content-transfer-encoding:mime-version:message-id:date:subject:cc
 :to:from:x-gm-message-state:from:to:cc:subject:date:message-id
 :reply-to;
 bh=pLqWwnXmtS1revD+osuVniPpZQCkZqNiibmgdQ7aHK4=;
 b=xCb8eN1GbYcwdBDt7esXeC7Xzj4UHWJTP2cpUmZ/lSpRLpBka53DKttQ+NqdtDPlNC
 OrJm90GICrE3RCGAM5MhvA5xT4MUVqj+qR6mzgQClmis6Ijld2kDhgAWFzfhl2cc20Nz
 tGIHHKCW2s3UXplkK6rgCULsOcaofbU5Nb+HWRAIuWt4b8OBg1O2ufwfmbVSLBItkhGj
 8kr1d9RR7s/e5sxvTKV3kkd8EtRtT74U1lN23ABfEpw8hWQptjHZcTzun2IDvcb6pklt
 p5oV+Mcg/0d9LRGXuvueL3XpKGEY6mW/0BKuH2j07SBI84vtNNAW1vL87RE9uJlbdzb4
 Alwg==
X-Gm-Message-State: AOJu0YzgSVN7XkzHYz2exCWf76dBemMiHtK5N8/QwAg2cL3SV3RXLBEV
 epb7PIUCe4iaTXB0e0OsJV0Rk5XmMD8=
X-Google-Smtp-Source: AGHT+IHnJxxgoAi/LL3f+YBbpEGTL4PvExpSvvFKgYizrjKWlR4aS3WrwjzZFC/g39Cp49HV9TURjg==
X-Received: by 2002:a05:600c:1c1b:b0:403:334:fb0d with SMTP id
 j27-20020a05600c1c1b00b004030334fb0dmr22443670wms.4.1699225264475; 
 Sun, 05 Nov 2023 15:01:04 -0800 (PST)
Received: from localhost.localdomain ([193.48.40.241])
 by smtp.gmail.com with ESMTPSA id
 q6-20020a05600c2e4600b003feae747ff2sm9977759wmf.35.2023.11.05.15.01.03
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sun, 05 Nov 2023 15:01:03 -0800 (PST)
From: Simon Tournier <zimon.toutoune@HIDDEN>
Date: Mon,  6 Nov 2023 00:00:55 +0100
Message-ID: <4be63ddf12bd6143b43e87951e164dc93c585bb8.1699225200.git.zimon.toutoune@HIDDEN>
X-Mailer: git-send-email 2.41.0
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Received-SPF: pass client-ip=2a00:1450:4864:20::330;
 envelope-from=zimon.toutoune@HIDDEN; helo=mail-wm1-x330.google.com
X-Spam_score_int: -20
X-Spam_score: -2.1
X-Spam_bar: --
X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001,
 RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001,
 T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 1.0 (+)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.0 (/)

Fixes <https://issues.guix.gnu.org/issue/65979>.
Reported by Simon Tournier <zimon.toutoune@HIDDEN>

* guix/hash.scm (vcs-file?): Add optional argument for passing VCS kind of the
file/repository.
(file-hash*): Adjust accordingly.
* guix/scripts/hash.scm (guix-hash)[file-hash]: Detect VCS kind of the
file/repository and passes it.

Change-Id: I8e286c3426ddefd664dc3a471d5a09e309824faa
---
 guix/hash.scm         | 18 ++++++++++++------
 guix/scripts/hash.scm | 18 +++++++++++++-----
 2 files changed, 25 insertions(+), 11 deletions(-)

Hi,

I re-resend this patch for more attractions in case I have missed
something. :-)  It had already been send more than 2 weeks ago as an answer to
#65979.

It fixes a corner case of "guix hash".

--8<---------------cut here---------------start------------->8---
$ git clone https://github.com/s-andrews/FastQC /tmp/FastQC
$ git -C /tmp/FastQC/ checkout v0.11.9

$ find /tmp/FastQC/ -type d -name ".git" -print
/tmp/FastQC/.git
$ find /tmp/FastQC/ -type d -name ".svn" -print
/tmp/FastQC/Help/1 Introduction/.svn
/tmp/FastQC/Help/3 Analysis Modules/.svn
/tmp/FastQC/Help/2 Basic Operations/.svn

$ guix hash -rx /tmp/FastQC
0jyk90kg6s62w3dn6qjx9nrawjs12qx172lii0yxbvsfylhnx479

$ grep -A 15 'define-public fastqc' gnu/packages/bioinformatics.scm | grep -C 1 base32
       (sha256
        (base32
         "00y9drm0bkpxw8xfl8ysss18jmnhj8blgqgr6fpa58rkpfcbg8qk"))

$ ./pre-inst-env guix hash -rx /tmp/FastQC
00y9drm0bkpxw8xfl8ysss18jmnhj8blgqgr6fpa58rkpfcbg8qk
--8<---------------cut here---------------end--------------->8---

And it does not introduce any significant penalty:

--8<---------------cut here---------------start------------->8---
$ time guix hash -rx .
093w70scf2v64bdbln5m2xjm63pzfib903w1mcb2smj32g0w8y63

real	0m9.730s
user	0m20.468s
sys	0m1.487s

$ time ./pre-inst-env guix hash -rx .
093w70scf2v64bdbln5m2xjm63pzfib903w1mcb2smj32g0w8y63

real	0m9.632s
user	0m20.320s
sys	0m1.541s
--8<---------------cut here---------------end--------------->8---


WDYT?

Cheers,
simon


diff --git a/guix/hash.scm b/guix/hash.scm
index 3cb68e5c44..8fff51e8f1 100644
--- a/guix/hash.scm
+++ b/guix/hash.scm
@@ -1,6 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2021 Sarah Morgensen <iskarian@HIDDEN>
 ;;; Copyright © 2022 Maxime Devos <maximedevos@HIDDEN>
+;;; Copyright © 2023 Simon Tournier <zimon.toutoune@HIDDEN>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -25,21 +26,26 @@ (define-module (guix hash)
   #:export (vcs-file?
             file-hash*))
 
-(define (vcs-file? file stat)
-  "Returns true if FILE is a version control system file."
+(define* (vcs-file? file stat
+                    #:optional
+                    (vcses (list ".bzr" ".git" ".hg" ".svn" "CVS")))
+  "Returns true if FILE matches a version control system from the list VCSES."
   (case (stat:type stat)
     ((directory)
-     (member (basename file) '(".bzr" ".git" ".hg" ".svn" "CVS")))
+     (member (basename file) vcses))
     ((regular)
-     ;; Git sub-modules have a '.git' file that is a regular text file.
-     (string=? (basename file) ".git"))
+     (if (member ".git" vcses)
+         ;; Git sub-modules have a '.git' file that is a regular text file.
+         (string=? (basename file) ".git")
+         #f))
     (else
      #f)))
 
 (define* (file-hash* file #:key
                      (algorithm (hash-algorithm sha256))
                      (recursive? 'auto)
-                     (select? (negate vcs-file?)))
+                     (select? (negate (lambda (file stat)
+                                        (vcs-file? file stat)))))
   "Compute the hash of FILE with ALGORITHM.
 
 Symbolic links are only dereferenced if RECURSIVE? is false.
diff --git a/guix/scripts/hash.scm b/guix/scripts/hash.scm
index 7197d3965c..ed96e6a7e1 100644
--- a/guix/scripts/hash.scm
+++ b/guix/scripts/hash.scm
@@ -3,7 +3,7 @@
 ;;; Copyright © 2013 Nikita Karetnikov <nikita@HIDDEN>
 ;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@HIDDEN>
 ;;; Copyright © 2018 Tim Gesthuizen <tim.gesthuizen@HIDDEN>
-;;; Copyright © 2021 Simon Tournier <zimon.toutoune@HIDDEN>
+;;; Copyright © 2021, 2023 Simon Tournier <zimon.toutoune@HIDDEN>
 ;;; Copyright © 2021 Sarah Morgensen <iskarian@HIDDEN>
 ;;;
 ;;; This file is part of GNU Guix.
@@ -181,9 +181,6 @@ (define-command (guix-hash . args)
                             (_ #f))
                            (reverse opts)))
          (fmt  (assq-ref opts 'format))
-         (select? (if (assq-ref opts 'exclude-vcs?)
-                      (negate vcs-file?)
-                      (const #t)))
          (algorithm (assoc-ref opts 'hash-algorithm))
          (serializer (assoc-ref opts 'serializer)))
 
@@ -193,7 +190,18 @@ (define-command (guix-hash . args)
       (catch 'system-error
         (lambda _
           (with-error-handling
-            (serializer file algorithm select?)))
+            (let* ((vcses (fold (lambda (vcs result)
+                                  (if (file-exists? (string-append file "/" vcs))
+                                      (cons vcs result)
+                                      result))
+                                '()
+                                (list ".bzr" ".git" ".hg" ".svn" "CVS")))
+                   (select? (if (assq-ref opts 'exclude-vcs?)
+                                (negate (lambda (file stat)
+                                          (vcs-file? file stat
+                                                     vcses)))
+                                (const #t))))
+              (serializer file algorithm select?))))
         (lambda args
           (leave (G_ "~a ~a~%")
                  file

base-commit: 08d94fe20eca47b69678b3eced8749dd02c700a4
-- 
2.41.0





Message sent:


Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-Mailer: MIME-tools 5.505 (Entity 5.505)
Content-Type: text/plain; charset=utf-8
X-Loop: help-debbugs@HIDDEN
From: help-debbugs@HIDDEN (GNU bug Tracking System)
To: Simon Tournier <zimon.toutoune@HIDDEN>
Subject: bug#66961: Acknowledgement ([PATCH] scripts: hash: Handle
 repository with different VCS folders.)
Message-ID: <handler.66961.B.169922531526446.ack <at> debbugs.gnu.org>
References: <4be63ddf12bd6143b43e87951e164dc93c585bb8.1699225200.git.zimon.toutoune@HIDDEN>
X-Gnu-PR-Message: ack 66961
X-Gnu-PR-Package: guix-patches
X-Gnu-PR-Keywords: patch
Reply-To: 66961 <at> debbugs.gnu.org
Date: Sun, 05 Nov 2023 23:02:01 +0000

Thank you for filing a new bug report with debbugs.gnu.org.

This is an automatically generated reply to let you know your message
has been received.

Your message is being forwarded to the package maintainers and other
interested parties for their attention; they will reply in due course.

As you requested using X-Debbugs-CC, your message was also forwarded to
  Christopher Baines <guix@HIDDEN>, Josselin Poiret <dev@HIDDEN>,=
 Ludovic Court=C3=A8s <ludo@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, =
Ricardo Wurmus <rekado@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN=
om>, Tobias Geerinckx-Rice <me@HIDDEN>
(after having been given a bug report number, if it did not have one).

Your message has been sent to the package maintainer(s):
 guix-patches@HIDDEN

If you wish to submit further information on this problem, please
send it to 66961 <at> debbugs.gnu.org.

Please do not send mail to help-debbugs@HIDDEN unless you wish
to report a problem with the Bug-tracking system.

--=20
66961: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D66961
GNU Bug Tracking System
Contact help-debbugs@HIDDEN with problems


Message sent to guix-patches@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: [bug#66961] [PATCH] scripts: hash: Handle repository with different VCS folders.
Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: guix-patches@HIDDEN
Resent-Date: Tue, 14 Nov 2023 13:46:02 +0000
Resent-Message-ID: <handler.66961.B66961.169996954818784 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 66961
X-GNU-PR-Package: guix-patches
X-GNU-PR-Keywords: patch
To: Simon Tournier <zimon.toutoune@HIDDEN>
Cc: Josselin Poiret <dev@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN>, 66961 <at> debbugs.gnu.org, Ricardo Wurmus <rekado@HIDDEN>, Christopher Baines <guix@HIDDEN>
Received: via spool by 66961-submit <at> debbugs.gnu.org id=B66961.169996954818784
          (code B ref 66961); Tue, 14 Nov 2023 13:46:02 +0000
Received: (at 66961) by debbugs.gnu.org; 14 Nov 2023 13:45:48 +0000
Received: from localhost ([127.0.0.1]:60529 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1r2tjf-0004su-Iq
	for submit <at> debbugs.gnu.org; Tue, 14 Nov 2023 08:45:47 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:45750)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1r2tjd-0004sd-RA
 for 66961 <at> debbugs.gnu.org; Tue, 14 Nov 2023 08:45:46 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <ludo@HIDDEN>)
 id 1r2tip-0004pJ-FZ; Tue, 14 Nov 2023 08:44:55 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To:
 From; bh=dgBzfZ8WLH55iw/qQuQ70zMagMfEOzJERWCTJSoMau0=; b=HLCrmym3IBXfPPs3xALK
 xMHFm+IsnVzKxKrH+w71nf7e8EFaAsfV5MrVDwWhbZn6a1Z2En+RT82PWVSK5LG75lVhqILGwrtgL
 DITG+Fz+1QKG9RBU7ACl4XVbm+qAXTLICP1sly3jFxgU6LlND89XciYCQHNOtyknKqkBkmaXjHQcS
 cJ9HQkd0fVYOVA3ckwel3cJObv/A7vbUiM9YjXjz59h/2jSDCQOoZkERbSFRIrqLRnvf/KAnvJym4
 ey1A2puZkw6RjswqZTfDBuvshFTei81fNJdXLFgxWsG8D7wJTM6tnsuYS+zjaU98eDMV+M6+a8qeY
 4NwjyXzUloV10Q==;
From: Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN>
In-Reply-To: <4be63ddf12bd6143b43e87951e164dc93c585bb8.1699225200.git.zimon.toutoune@HIDDEN>
 (Simon Tournier's message of "Mon, 6 Nov 2023 00:00:55 +0100")
References: <4be63ddf12bd6143b43e87951e164dc93c585bb8.1699225200.git.zimon.toutoune@HIDDEN>
Date: Tue, 14 Nov 2023 14:44:52 +0100
Message-ID: <87zfzg8n57.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -2.3 (--)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Hi!

Simon Tournier <zimon.toutoune@HIDDEN> skribis:

> Fixes <https://issues.guix.gnu.org/issue/65979>.
> Reported by Simon Tournier <zimon.toutoune@HIDDEN>
>
> * guix/hash.scm (vcs-file?): Add optional argument for passing VCS kind o=
f the
> file/repository.
> (file-hash*): Adjust accordingly.
> * guix/scripts/hash.scm (guix-hash)[file-hash]: Detect VCS kind of the
> file/repository and passes it.
>
> Change-Id: I8e286c3426ddefd664dc3a471d5a09e309824faa

[...]

> +(define* (vcs-file? file stat
> +                    #:optional
> +                    (vcses (list ".bzr" ".git" ".hg" ".svn" "CVS")))
> +  "Returns true if FILE matches a version control system from the list V=
CSES."

How about =E2=80=98vcs-directories=E2=80=99 rather than =E2=80=98vcses=E2=
=80=99?

Also, you can add:

  (define %known-vcs-directories
    '(".bzr" =E2=80=A6))

and use it to avoid repeating it.

> +            (let* ((vcses (fold (lambda (vcs result)
> +                                  (if (file-exists? (string-append file =
"/" vcs))
> +                                      (cons vcs result)
> +                                      result))
> +                                '()
> +                                (list ".bzr" ".git" ".hg" ".svn" "CVS")))
> +                   (select? (if (assq-ref opts 'exclude-vcs?)
> +                                (negate (lambda (file stat)
> +                                          (vcs-file? file stat
> +                                                     vcses)))
> +                                (const #t))))

Maybe you can have:

  (define (vcs-predicate directory)
    (define directories
      (filter (lambda (metadata-directory)
                (file-exists? (in-vicinity directory metadata-directory)))
              %known-vcs-directories))

    (lambda (file stat)
      (vcs-file? file stat directories)))

and then use that above?  (That way we don=E2=80=99t stat these things when
=E2=80=98exclude-vcs?=E2=80=99 is #false.)

Thanks,
Ludo=E2=80=99.




Message sent to guix@HIDDEN, dev@HIDDEN, ludo@HIDDEN, othacehe@HIDDEN, rekado@HIDDEN, zimon.toutoune@HIDDEN, me@HIDDEN, guix-patches@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: [bug#66961] [PATCH v2] scripts: hash: Handle repository with different VCS folders.
References: <4be63ddf12bd6143b43e87951e164dc93c585bb8.1699225200.git.zimon.toutoune@HIDDEN>
In-Reply-To: <4be63ddf12bd6143b43e87951e164dc93c585bb8.1699225200.git.zimon.toutoune@HIDDEN>
Resent-From: Simon Tournier <zimon.toutoune@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: guix@HIDDEN, dev@HIDDEN, ludo@HIDDEN, othacehe@HIDDEN, rekado@HIDDEN, zimon.toutoune@HIDDEN, me@HIDDEN, guix-patches@HIDDEN
Resent-Date: Wed, 29 Nov 2023 20:32:02 +0000
Resent-Message-ID: <handler.66961.B66961.170128988329303 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 66961
X-GNU-PR-Package: guix-patches
X-GNU-PR-Keywords: patch
To: 66961 <at> debbugs.gnu.org
Cc: Simon Tournier <zimon.toutoune@HIDDEN>, Christopher Baines <guix@HIDDEN>, Josselin Poiret <dev@HIDDEN>, Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Ricardo Wurmus <rekado@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN>
X-Debbugs-Original-Xcc: Christopher Baines <guix@HIDDEN>, Josselin Poiret <dev@HIDDEN>, Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Ricardo Wurmus <rekado@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN>
Received: via spool by 66961-submit <at> debbugs.gnu.org id=B66961.170128988329303
          (code B ref 66961); Wed, 29 Nov 2023 20:32:02 +0000
Received: (at 66961) by debbugs.gnu.org; 29 Nov 2023 20:31:23 +0000
Received: from localhost ([127.0.0.1]:51532 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1r8RDO-0007cZ-N1
	for submit <at> debbugs.gnu.org; Wed, 29 Nov 2023 15:31:23 -0500
Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]:40994)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <zimon.toutoune@HIDDEN>) id 1r8RDN-0007cJ-3A
 for 66961 <at> debbugs.gnu.org; Wed, 29 Nov 2023 15:31:22 -0500
Received: by mail-wm1-x32f.google.com with SMTP id
 5b1f17b1804b1-40b5149a4efso234595e9.0
 for <66961 <at> debbugs.gnu.org>; Wed, 29 Nov 2023 12:31:13 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1701289867; x=1701894667; darn=debbugs.gnu.org;
 h=content-transfer-encoding:mime-version:message-id:date:subject:cc
 :to:from:from:to:cc:subject:date:message-id:reply-to;
 bh=hmD4Ee2e8M6IE93thyJrcKcGROQxBXOTDHmnII2yxjQ=;
 b=KtYGff8bBehN0FhLzf+A4hDpw6GLOFRGtHduWTkyrF3nxEAXBEavJbhCgwRrBe7q4K
 HSONzqRc80oiL9LcLjRA+pioidXSq6Wj4JwEriXbf/DeGWo7NgDCpTOXuQIkhqM7AOJo
 fiXCEb5b9yfUNJ5tJA3jRhNILaIYtlQWkdtm5UUWtouCpULAv99vkxrqNFG4Hn/aNLDs
 Icw2npGz7HouVMH8vbn4lTr2M6xugvMfwWPROV+67k6o/2azpqJXK1WaBzZ2yXOffJn+
 98lzxvDCp41cJyOQvx8zeBASM79NBOtBZ393pftfDtiPABGEYtNMlHlAxJaT4ueZOYKd
 43bw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1701289867; x=1701894667;
 h=content-transfer-encoding:mime-version:message-id:date:subject:cc
 :to:from:x-gm-message-state:from:to:cc:subject:date:message-id
 :reply-to;
 bh=hmD4Ee2e8M6IE93thyJrcKcGROQxBXOTDHmnII2yxjQ=;
 b=F2GtgzWM04/Ls+wIrhpumr+q7Sqtk3r7ek6sMY4spBE5jItQh3Xm8eBb5eOUpWFn81
 3pAnzOlFdSMVM8zDTNEokCO+GdLsS1n5WNCvqZmK+amGuYTkwXEHU0lCcfp485hhFoHa
 eUEqpY1EdWIOGHpeTDQrVkU5Hfr7ibmw96GeJP4MTKVVjf5+Kp6VOE6sSE1cyTH+3mGP
 EquuG3d5M4ezyskzxauZL7g4sJXTd0ctv+6c16cEKP6POCRoK0NBlN9U6W+8S5yHKeEE
 ZhaBJXAufr/7CYKxQQRI8/mW1cGEMSOowoDOT/TysSIIZKn43X3hePjhr3bm4v1iUDcX
 wl4A==
X-Gm-Message-State: AOJu0Yz7xSVMW/EsTAbtbiALGnuUcZb3b8Hx013zMmQgsEChDmzOrNGE
 8Uzf67tKVd7poi79WQXdN5tkqG5t/5g=
X-Google-Smtp-Source: AGHT+IELki/nIkf/QhYE3tJfFfahJtSbe4Vmbra9CZ7ecbUQ27Qb8q8FHL/AMuFBjonQ0nloUOkoYQ==
X-Received: by 2002:a05:600c:2219:b0:40b:4889:667e with SMTP id
 z25-20020a05600c221900b0040b4889667emr6353795wml.4.1701289867235; 
 Wed, 29 Nov 2023 12:31:07 -0800 (PST)
Received: from lili.home (2a01cb04060a11004b3b81ecb857e340.ipv6.abo.wanadoo.fr.
 [2a01:cb04:60a:1100:4b3b:81ec:b857:e340])
 by smtp.gmail.com with ESMTPSA id
 r14-20020a05600c458e00b0040a4751efaasm3365469wmo.17.2023.11.29.12.31.06
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Wed, 29 Nov 2023 12:31:06 -0800 (PST)
From: Simon Tournier <zimon.toutoune@HIDDEN>
Date: Wed, 29 Nov 2023 21:31:00 +0100
Message-ID: <adfd8ba3e41841d280b873ed4199607b0bcfae52.1701289675.git.zimon.toutoune@HIDDEN>
X-Mailer: git-send-email 2.41.0
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Spam-Score: -0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Fixes <https://issues.guix.gnu.org/issue/65979>.
Reported by Simon Tournier <zimon.toutoune@HIDDEN>

* guix/hash.scm (%vcs-directories): New variable.
(vcs-file?): Add optional argument for passing VCS kind of the
file/repository.
(file-hash*): Adjust accordingly.
(vcs-exclude?): New procedure and export it.
* guix/scripts/hash.scm (guix-hash): Use it.

Change-Id: I8e286c3426ddefd664dc3a471d5a09e309824faa
---
 guix/hash.scm         | 34 ++++++++++++++++++++++++++++------
 guix/scripts/hash.scm |  2 +-
 2 files changed, 29 insertions(+), 7 deletions(-)

diff --git a/guix/hash.scm b/guix/hash.scm
index 3cb68e5c44..650def0696 100644
--- a/guix/hash.scm
+++ b/guix/hash.scm
@@ -1,6 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2021 Sarah Morgensen <iskarian@HIDDEN>
 ;;; Copyright © 2022 Maxime Devos <maximedevos@HIDDEN>
+;;; Copyright © 2023 Simon Tournier <zimon.toutoune@HIDDEN>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -23,23 +24,44 @@ (define-module (guix hash)
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-11)
   #:export (vcs-file?
+            vcs-exclude?
             file-hash*))
 
-(define (vcs-file? file stat)
-  "Returns true if FILE is a version control system file."
+(define %vcs-directories
+  ;; Directory used for determining the kind of VCS.
+  (list ".bzr" ".git" ".hg" ".svn" "CVS"))
+
+(define* (vcs-file? file stat
+                    #:optional
+                    (vcs-directories %vcs-directories))
+  "Return true if FILE matches a version control system from the list
+VCSES-DIRECTORIES."
   (case (stat:type stat)
     ((directory)
-     (member (basename file) '(".bzr" ".git" ".hg" ".svn" "CVS")))
+     (member (basename file) vcs-directories))
     ((regular)
-     ;; Git sub-modules have a '.git' file that is a regular text file.
-     (string=? (basename file) ".git"))
+     (if (member ".git" vcs-directories)
+         ;; Git sub-modules have a '.git' file that is a regular text file.
+         (string=? (basename file) ".git")
+         #f))
     (else
      #f)))
 
+(define (vcs-exclude? directory)
+  "Return a procedure excluding content if DIRECTORY contains supported VCS."
+  (define vcs-directories
+    (filter (lambda (vcs)
+              (file-exists? (in-vicinity directory vcs)))
+            %vcs-directories))
+
+  (lambda (file stat)
+    (not (vcs-file? file stat vcs-directories))))
+
 (define* (file-hash* file #:key
                      (algorithm (hash-algorithm sha256))
                      (recursive? 'auto)
-                     (select? (negate vcs-file?)))
+                     (select? (negate (lambda (file stat)
+                                        (vcs-file? file stat)))))
   "Compute the hash of FILE with ALGORITHM.
 
 Symbolic links are only dereferenced if RECURSIVE? is false.
diff --git a/guix/scripts/hash.scm b/guix/scripts/hash.scm
index 7197d3965c..b6af9d5649 100644
--- a/guix/scripts/hash.scm
+++ b/guix/scripts/hash.scm
@@ -182,7 +182,7 @@ (define-command (guix-hash . args)
                            (reverse opts)))
          (fmt  (assq-ref opts 'format))
          (select? (if (assq-ref opts 'exclude-vcs?)
-                      (negate vcs-file?)
+                      (vcs-exclude? file)
                       (const #t)))
          (algorithm (assoc-ref opts 'hash-algorithm))
          (serializer (assoc-ref opts 'serializer)))

base-commit: cd46757c1a0f886848fbb6828c028dd2a2532767
-- 
2.41.0





Message sent to guix@HIDDEN, dev@HIDDEN, ludo@HIDDEN, othacehe@HIDDEN, rekado@HIDDEN, zimon.toutoune@HIDDEN, me@HIDDEN, guix-patches@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: [bug#66961] [PATCH v3] scripts: hash: Handle repository with different VCS folders.
References: <4be63ddf12bd6143b43e87951e164dc93c585bb8.1699225200.git.zimon.toutoune@HIDDEN>
In-Reply-To: <4be63ddf12bd6143b43e87951e164dc93c585bb8.1699225200.git.zimon.toutoune@HIDDEN>
Resent-From: Simon Tournier <zimon.toutoune@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: guix@HIDDEN, dev@HIDDEN, ludo@HIDDEN, othacehe@HIDDEN, rekado@HIDDEN, zimon.toutoune@HIDDEN, me@HIDDEN, guix-patches@HIDDEN
Resent-Date: Wed, 29 Nov 2023 20:55:01 +0000
Resent-Message-ID: <handler.66961.B66961.170129126631906 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 66961
X-GNU-PR-Package: guix-patches
X-GNU-PR-Keywords: patch
To: 66961 <at> debbugs.gnu.org
Cc: Simon Tournier <zimon.toutoune@HIDDEN>, Christopher Baines <guix@HIDDEN>, Josselin Poiret <dev@HIDDEN>, Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Ricardo Wurmus <rekado@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN>
X-Debbugs-Original-Xcc: Christopher Baines <guix@HIDDEN>, Josselin Poiret <dev@HIDDEN>, Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Ricardo Wurmus <rekado@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN>
Received: via spool by 66961-submit <at> debbugs.gnu.org id=B66961.170129126631906
          (code B ref 66961); Wed, 29 Nov 2023 20:55:01 +0000
Received: (at 66961) by debbugs.gnu.org; 29 Nov 2023 20:54:26 +0000
Received: from localhost ([127.0.0.1]:51590 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1r8RZi-0008IX-5T
	for submit <at> debbugs.gnu.org; Wed, 29 Nov 2023 15:54:26 -0500
Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]:40060)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <zimon.toutoune@HIDDEN>) id 1r8RZf-0008IJ-Kr
 for 66961 <at> debbugs.gnu.org; Wed, 29 Nov 2023 15:54:24 -0500
Received: by mail-wr1-x431.google.com with SMTP id
 ffacd0b85a97d-3316d855828so43217f8f.0
 for <66961 <at> debbugs.gnu.org>; Wed, 29 Nov 2023 12:54:15 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1701291250; x=1701896050; darn=debbugs.gnu.org;
 h=content-transfer-encoding:mime-version:message-id:date:subject:cc
 :to:from:from:to:cc:subject:date:message-id:reply-to;
 bh=+g9zgFox1WA0+ttxLLokz6eTRxjtsQ7tf8MQus1QiKo=;
 b=UbaTJFvBoySv/Y373+uu7YBfj3dPQLlDaTqZ70OfQaBTLUA/U4kLVGHynk91mm2pV2
 gdsfdAN0O99bg4O7G1i9BTmPzI1a6NILpxTW32CRdTYqPwikknTHjkHNt+M04+28KP20
 /SUHF5tgaGTZ8PZ4reCr+uH2hEPbdFUSBVG4Ofl1e9vDXjwBMs1L7OJ9pA3mrwqbtDdk
 JTMAn4nC2rErfvlDJAXBNuX9lAzJhtagzed7KqUVGjKUydOn2HJzVSO8LqRIO48o1MCt
 8tXjQ4R4ojOm2VM+ZSZlPPrSt3c+Wb4VpabwdU1eaoYRGSnkExqF41Y2ndXgms4lGv+x
 THeQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1701291250; x=1701896050;
 h=content-transfer-encoding:mime-version:message-id:date:subject:cc
 :to:from:x-gm-message-state:from:to:cc:subject:date:message-id
 :reply-to;
 bh=+g9zgFox1WA0+ttxLLokz6eTRxjtsQ7tf8MQus1QiKo=;
 b=qnCgi1gR8df3GtSrLzWbOLhu92R3vAeu5oB/FOsPpAP2tLb5/62tDtouQoe2B89Kfh
 6ODpLF+rwi3eBO1UTI4qvT9k0YXvPUJDZ8tt/uCu++4pf72PGPg4rPCDnY6YUE11Rfbg
 z3uSy4CBMlKwFUTq276ZBHW20ut7gPJsK29C28IhCWtfLy8vUqzEsBVXY7CaZ/LUrBGb
 cbYvQlsuqfg0iWXsJHefT1IUltXFbjeQjcY5eYkdhNhym5AUGW7mPHS2UlY9iQLXVXeo
 cKOCnL/MVzBCHHMZ07SUHE0HrvBak5NhPqhcjViVulDEBbncJkEcK0IiUZPJIWSX30ID
 rwEQ==
X-Gm-Message-State: AOJu0YxeVXcBKj5Sk8nQXQa9afNjUgGOuMnclz7vmWiECfLCc2F+bUEC
 h1Wj7/cC422xwdIiCUbWEdkiD/ZQPVI=
X-Google-Smtp-Source: AGHT+IE0kNUuI816YF0wiLwONGwYDH6MFNOE4nRBe82ue64sIgGLCijnbmxSyAG3KZTg1vSWwkdR9w==
X-Received: by 2002:a05:6000:4011:b0:332:e749:adaa with SMTP id
 cp17-20020a056000401100b00332e749adaamr13264355wrb.3.1701291249890; 
 Wed, 29 Nov 2023 12:54:09 -0800 (PST)
Received: from lili.home (2a01cb04060a11004b3b81ecb857e340.ipv6.abo.wanadoo.fr.
 [2a01:cb04:60a:1100:4b3b:81ec:b857:e340])
 by smtp.gmail.com with ESMTPSA id
 w27-20020adf8bdb000000b00332e5624a31sm18234719wra.84.2023.11.29.12.54.08
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Wed, 29 Nov 2023 12:54:09 -0800 (PST)
From: Simon Tournier <zimon.toutoune@HIDDEN>
Date: Wed, 29 Nov 2023 21:54:03 +0100
Message-ID: <6a560e37ba23e43d35c0b62c1ee860b4341c263c.1701290895.git.zimon.toutoune@HIDDEN>
X-Mailer: git-send-email 2.41.0
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Spam-Score: -0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Fixes <https://issues.guix.gnu.org/issue/65979>.
Reported by Simon Tournier <zimon.toutoune@HIDDEN>

* guix/hash.scm (%vcs-directories): New variable.
(vcs-file?): Add optional argument for passing VCS kind of the
file/repository.
(file-hash*): Adjust accordingly.
(vcs-exclude?): New procedure and export it.
* guix/scripts/hash.scm (guix-hash)[file-hash]: Use it.

Change-Id: I8e286c3426ddefd664dc3a471d5a09e309824faa
---
 guix/hash.scm         | 34 ++++++++++++++++++++++++++++------
 guix/scripts/hash.scm | 10 +++++-----
 2 files changed, 33 insertions(+), 11 deletions(-)

diff --git a/guix/hash.scm b/guix/hash.scm
index 3cb68e5c44..650def0696 100644
--- a/guix/hash.scm
+++ b/guix/hash.scm
@@ -1,6 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2021 Sarah Morgensen <iskarian@HIDDEN>
 ;;; Copyright © 2022 Maxime Devos <maximedevos@HIDDEN>
+;;; Copyright © 2023 Simon Tournier <zimon.toutoune@HIDDEN>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -23,23 +24,44 @@ (define-module (guix hash)
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-11)
   #:export (vcs-file?
+            vcs-exclude?
             file-hash*))
 
-(define (vcs-file? file stat)
-  "Returns true if FILE is a version control system file."
+(define %vcs-directories
+  ;; Directory used for determining the kind of VCS.
+  (list ".bzr" ".git" ".hg" ".svn" "CVS"))
+
+(define* (vcs-file? file stat
+                    #:optional
+                    (vcs-directories %vcs-directories))
+  "Return true if FILE matches a version control system from the list
+VCSES-DIRECTORIES."
   (case (stat:type stat)
     ((directory)
-     (member (basename file) '(".bzr" ".git" ".hg" ".svn" "CVS")))
+     (member (basename file) vcs-directories))
     ((regular)
-     ;; Git sub-modules have a '.git' file that is a regular text file.
-     (string=? (basename file) ".git"))
+     (if (member ".git" vcs-directories)
+         ;; Git sub-modules have a '.git' file that is a regular text file.
+         (string=? (basename file) ".git")
+         #f))
     (else
      #f)))
 
+(define (vcs-exclude? directory)
+  "Return a procedure excluding content if DIRECTORY contains supported VCS."
+  (define vcs-directories
+    (filter (lambda (vcs)
+              (file-exists? (in-vicinity directory vcs)))
+            %vcs-directories))
+
+  (lambda (file stat)
+    (not (vcs-file? file stat vcs-directories))))
+
 (define* (file-hash* file #:key
                      (algorithm (hash-algorithm sha256))
                      (recursive? 'auto)
-                     (select? (negate vcs-file?)))
+                     (select? (negate (lambda (file stat)
+                                        (vcs-file? file stat)))))
   "Compute the hash of FILE with ALGORITHM.
 
 Symbolic links are only dereferenced if RECURSIVE? is false.
diff --git a/guix/scripts/hash.scm b/guix/scripts/hash.scm
index 7197d3965c..8982bb37b9 100644
--- a/guix/scripts/hash.scm
+++ b/guix/scripts/hash.scm
@@ -3,7 +3,7 @@
 ;;; Copyright © 2013 Nikita Karetnikov <nikita@HIDDEN>
 ;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@HIDDEN>
 ;;; Copyright © 2018 Tim Gesthuizen <tim.gesthuizen@HIDDEN>
-;;; Copyright © 2021 Simon Tournier <zimon.toutoune@HIDDEN>
+;;; Copyright © 2021, 2023 Simon Tournier <zimon.toutoune@HIDDEN>
 ;;; Copyright © 2021 Sarah Morgensen <iskarian@HIDDEN>
 ;;;
 ;;; This file is part of GNU Guix.
@@ -181,9 +181,6 @@ (define-command (guix-hash . args)
                             (_ #f))
                            (reverse opts)))
          (fmt  (assq-ref opts 'format))
-         (select? (if (assq-ref opts 'exclude-vcs?)
-                      (negate vcs-file?)
-                      (const #t)))
          (algorithm (assoc-ref opts 'hash-algorithm))
          (serializer (assoc-ref opts 'serializer)))
 
@@ -193,7 +190,10 @@ (define-command (guix-hash . args)
       (catch 'system-error
         (lambda _
           (with-error-handling
-            (serializer file algorithm select?)))
+            (let ((select? (if (assq-ref opts 'exclude-vcs?)
+                               (vcs-exclude? file)
+                               (const #t))))
+              (serializer file algorithm select?))))
         (lambda args
           (leave (G_ "~a ~a~%")
                  file

base-commit: cd46757c1a0f886848fbb6828c028dd2a2532767
-- 
2.41.0





Message sent to guix-patches@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: [bug#66961] [PATCH] scripts: hash: Handle repository with different VCS folders.
Resent-From: Simon Tournier <zimon.toutoune@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: guix-patches@HIDDEN
Resent-Date: Thu, 30 Nov 2023 09:29:03 +0000
Resent-Message-ID: <handler.66961.B66961.17013365096646 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 66961
X-GNU-PR-Package: guix-patches
X-GNU-PR-Keywords: patch
To: Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN>
Cc: Josselin Poiret <dev@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN>, 66961 <at> debbugs.gnu.org, Ricardo Wurmus <rekado@HIDDEN>, Christopher Baines <guix@HIDDEN>
Received: via spool by 66961-submit <at> debbugs.gnu.org id=B66961.17013365096646
          (code B ref 66961); Thu, 30 Nov 2023 09:29:03 +0000
Received: (at 66961) by debbugs.gnu.org; 30 Nov 2023 09:28:29 +0000
Received: from localhost ([127.0.0.1]:52301 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1r8dLQ-0001iw-FF
	for submit <at> debbugs.gnu.org; Thu, 30 Nov 2023 04:28:28 -0500
Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]:41183)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <zimon.toutoune@HIDDEN>) id 1r8dLO-0001i6-23
 for 66961 <at> debbugs.gnu.org; Thu, 30 Nov 2023 04:28:26 -0500
Received: by mail-wm1-x32a.google.com with SMTP id
 5b1f17b1804b1-40b5149a4efso601985e9.0
 for <66961 <at> debbugs.gnu.org>; Thu, 30 Nov 2023 01:28:17 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1701336492; x=1701941292; darn=debbugs.gnu.org;
 h=content-transfer-encoding:mime-version:message-id:date:references
 :in-reply-to:subject:cc:to:from:from:to:cc:subject:date:message-id
 :reply-to; bh=i7b0CVWzqNVdhCLli9eYkAZEpYul3Mvq/r6uuJih7+0=;
 b=J0bw17g2iAwh/sjSklpyj0ji8OMoVGt28adQMbWDt4/nX8J8cve1tbtgn5N+emB1P4
 0eHH/m2a3JSZcbF7bVefJwQr+nxHXTLykOTfBSA1FsOHkvuA6kI/7n8OXUwY1qlQiCxw
 wEEXsyf14cKpsztXpqojGKhCPTl2mUa7RGGpfznBG4adw2t4A2kX7zHSgiTTT9OxhND8
 3ojlNZRttFG/Q73mO7bSeGiXMsygUZ1S4VA9qJ6Njoy4q7HeLGfdR96feUYohLQMLC4D
 D4pBnxSNUmZ1762RN1qeGDsAPY29jhRqCukGQpiuEIkqJi44kvJNH7b1b484gr3+h7Lk
 zhuA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1701336492; x=1701941292;
 h=content-transfer-encoding:mime-version:message-id:date:references
 :in-reply-to:subject:cc:to:from:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=i7b0CVWzqNVdhCLli9eYkAZEpYul3Mvq/r6uuJih7+0=;
 b=V7LcHQ76d2n0DjQA8wCkdofKyDrH0qTJTT3jh6KXLuib/1CFT7f0N5wpX0fp9w1r9y
 2BOBq5TTIqUJga1FIWjga+PP4bCq0bLmUlNRKH5ir0+M5hOoZcoeqh7Z740fqzF98QFl
 BdUYVlEfYjvUxeHzbCrn2z7RUJOuKtwHpzOYBKMw5BxlTC9LQAo6+GXck8C5WRjrVFAr
 avLkzue00gSXtcZ1pnA04x/B7et/Tj8P2CMQkYvtoetkcN1sdtzODtUERvrSoW355vT9
 b2FzCriNsWso/UtwDygByi8459DfvBt/El3Jl9MmptqU7gsnlVh8oS1QpBf935bwL5tX
 GZew==
X-Gm-Message-State: AOJu0YyzPWCpjLli25S2viH7ngX6pk2DdDynSc2BztoO1GWg9vyONQTt
 ZOOuyI5VVYx8MDt0a0ObK6pqV7/rUHM=
X-Google-Smtp-Source: AGHT+IE23agydLuYDPqeZ4JGh7qNxV+kVje+9Jk2rOPgLvfkFXtDf5PCuyk8lqkaXQa/RboHJ9z8yg==
X-Received: by 2002:a05:600c:1d06:b0:40b:5150:c046 with SMTP id
 l6-20020a05600c1d0600b0040b5150c046mr3559529wms.3.1701336492198; 
 Thu, 30 Nov 2023 01:28:12 -0800 (PST)
Received: from lili (roam-nat-fw-prg-194-254-61-42.net.univ-paris-diderot.fr.
 [194.254.61.42]) by smtp.gmail.com with ESMTPSA id
 bg24-20020a05600c3c9800b0040b3d33ab55sm5014410wmb.47.2023.11.30.01.28.10
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Thu, 30 Nov 2023 01:28:11 -0800 (PST)
From: Simon Tournier <zimon.toutoune@HIDDEN>
In-Reply-To: <87zfzg8n57.fsf@HIDDEN>
References: <4be63ddf12bd6143b43e87951e164dc93c585bb8.1699225200.git.zimon.toutoune@HIDDEN>
 <87zfzg8n57.fsf@HIDDEN>
Date: Wed, 29 Nov 2023 21:36:31 +0100
Message-ID: <871qc85mb4.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 0.8 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.2 (/)

Hi Ludo,

On mar., 14 nov. 2023 at 14:44, Ludovic Court=C3=A8s <ludo@HIDDEN> wrote:

> How about =E2=80=98vcs-directories=E2=80=99 rather than =E2=80=98vcses=E2=
=80=99?
>
> Also, you can add:
>
>   (define %known-vcs-directories
>     '(".bzr" =E2=80=A6))
>
> and use it to avoid repeating it.

[...]

> Maybe you can have:
>
>   (define (vcs-predicate directory)
>     (define directories
>       (filter (lambda (metadata-directory)
>                 (file-exists? (in-vicinity directory metadata-directory)))
>               %known-vcs-directories))
>
>     (lambda (file stat)
>       (vcs-file? file stat directories)))
>
> and then use that above?  (That way we don=E2=80=99t stat these things wh=
en
> =E2=80=98exclude-vcs?=E2=80=99 is #false.)

Thanks for the feedback.  See v2.

Cheers,
simon

PS: Sorry, I have sent twice v2; missed an option with my new
experimental setup. :-)




Message sent to guix-patches@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: [bug#66961] [PATCH] scripts: hash: Handle repository with different VCS folders.
Resent-From: Simon Tournier <zimon.toutoune@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: guix-patches@HIDDEN
Resent-Date: Thu, 30 Nov 2023 09:29:03 +0000
Resent-Message-ID: <handler.66961.B66961.17013365306680 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 66961
X-GNU-PR-Package: guix-patches
X-GNU-PR-Keywords: patch
To: Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN>
Cc: Josselin Poiret <dev@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN>, 66961 <at> debbugs.gnu.org, Ricardo Wurmus <rekado@HIDDEN>, Christopher Baines <guix@HIDDEN>
Received: via spool by 66961-submit <at> debbugs.gnu.org id=B66961.17013365306680
          (code B ref 66961); Thu, 30 Nov 2023 09:29:03 +0000
Received: (at 66961) by debbugs.gnu.org; 30 Nov 2023 09:28:50 +0000
Received: from localhost ([127.0.0.1]:52303 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1r8dLm-0001jg-00
	for submit <at> debbugs.gnu.org; Thu, 30 Nov 2023 04:28:50 -0500
Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]:39121)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <zimon.toutoune@HIDDEN>) id 1r8dLQ-0001iL-8L
 for 66961 <at> debbugs.gnu.org; Thu, 30 Nov 2023 04:28:28 -0500
Received: by mail-wm1-x331.google.com with SMTP id
 5b1f17b1804b1-40b36e721fcso720845e9.0
 for <66961 <at> debbugs.gnu.org>; Thu, 30 Nov 2023 01:28:20 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1701336494; x=1701941294; darn=debbugs.gnu.org;
 h=mime-version:message-id:date:references:in-reply-to:subject:cc:to
 :from:from:to:cc:subject:date:message-id:reply-to;
 bh=Bd0ZnuKrdhsajS0Er8SJ+QMhyUrevQSZIpH/9dOeN4c=;
 b=iAB3Kd8JTOJaccMWau5Ngg5mYHtsRXiIrv9RGtp+EO6fu0UJZQzT4YDF9iyGmJHx9J
 MVkVkYPTw6NlESF/3OGQUj1JyeXvHqmy/TFSn3TxpztKEBmbR32q4JTZiJS/9Q6WpdX9
 CYPPDRq6/+QX+AIXbfgG3zaTKsaBo25xgEc0Grkl50SgzfAa7qMKAvNkg4wi1K9A/0vN
 GFfQlzFVl4Ip0fsSNwDzqQa6LHKDJpP5Wowzg0zJzCTanqtMjrMRq/IHLxlqbP5ayOKF
 ZNiXFP8vBglfVEiDsnOHLHaItdUOgJxPX6ZGzegygB4pIgM+1RC1sanUPC7ANv6rmNUZ
 EtfA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1701336494; x=1701941294;
 h=mime-version:message-id:date:references:in-reply-to:subject:cc:to
 :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
 bh=Bd0ZnuKrdhsajS0Er8SJ+QMhyUrevQSZIpH/9dOeN4c=;
 b=pydSv9FiAbXGGhOjVKCwdL3+ql76oVGg3C7VaaPMfQEF5xLpRleLcIhbZ6xeeLbdTH
 AkPahhYQseyPgiqfLCjsf+lGNJu6azq1qKKkvb2wvrey41Z/NCczLwNv/2JLBmmkaBdH
 gYSQMdcevaWKihBSTXDe0L41EuTudDs6bcV5Bq5N2RYFzDkyfPjNZv9aCboVFBKBrCA3
 rvukxvmVn7mkUaSHV/2k6g7beurT5SpibxBXwPWGFqQom49UyUTn4VVPSD4Dm13jyDn7
 LPrzwVzDG+JoObAVpYPNjVHN5OBjSufmQRwpoukc9Br33fxXbnFT03nPVXgGDatbKVe5
 Kc8A==
X-Gm-Message-State: AOJu0Yxo31V1DUu1++X4BKftaFUSkBpBLC33vB15Wo+cHUF99/ok4geN
 h7oYEB9S6wak2pfTHcDShws=
X-Google-Smtp-Source: AGHT+IFL7wo7hKqh0lRASxn7E8+euzUdh2XstSXgAdiFoQ8wDW4vWopyG3cxjec/qom2+2tQDbWOcw==
X-Received: by 2002:a05:600c:5115:b0:40b:2971:4b73 with SMTP id
 o21-20020a05600c511500b0040b29714b73mr816157wms.2.1701336494467; 
 Thu, 30 Nov 2023 01:28:14 -0800 (PST)
Received: from lili (roam-nat-fw-prg-194-254-61-43.net.univ-paris-diderot.fr.
 [194.254.61.43]) by smtp.gmail.com with ESMTPSA id
 h6-20020a05600c350600b0040b43da0bbasm1257652wmq.30.2023.11.30.01.28.12
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Thu, 30 Nov 2023 01:28:14 -0800 (PST)
From: Simon Tournier <zimon.toutoune@HIDDEN>
In-Reply-To: <871qc85mb4.fsf@HIDDEN>
References: <4be63ddf12bd6143b43e87951e164dc93c585bb8.1699225200.git.zimon.toutoune@HIDDEN>
 <87zfzg8n57.fsf@HIDDEN> <871qc85mb4.fsf@HIDDEN>
Date: Wed, 29 Nov 2023 21:52:56 +0100
Message-ID: <87wmu046zb.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.8 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.2 (/)

On mer., 29 nov. 2023 at 21:36, Simon Tournier <zimon.toutoune@HIDDEN> wrote:

> Thanks for the feedback.  See v2.

[...]

> PS: Sorry, I have sent twice v2; missed an option with my new
> experimental setup. :-)

Sorry for the mess.  I have sent the correct one; v2 is obviously-
broken.  Therefore, please see v3.  Again sorry for the mess.

Cheers,
simon




Message sent to guix-patches@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: [bug#66961] [PATCH v3] scripts: hash: Handle repository with different VCS folders.
Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: guix-patches@HIDDEN
Resent-Date: Sat, 02 Dec 2023 10:41:02 +0000
Resent-Message-ID: <handler.66961.B66961.170151361211961 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 66961
X-GNU-PR-Package: guix-patches
X-GNU-PR-Keywords: patch
To: Simon Tournier <zimon.toutoune@HIDDEN>
Cc: Josselin Poiret <dev@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN>, 66961 <at> debbugs.gnu.org, Ricardo Wurmus <rekado@HIDDEN>, Christopher Baines <guix@HIDDEN>
Received: via spool by 66961-submit <at> debbugs.gnu.org id=B66961.170151361211961
          (code B ref 66961); Sat, 02 Dec 2023 10:41:02 +0000
Received: (at 66961) by debbugs.gnu.org; 2 Dec 2023 10:40:12 +0000
Received: from localhost ([127.0.0.1]:56716 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1r9NPv-00036r-T3
	for submit <at> debbugs.gnu.org; Sat, 02 Dec 2023 05:40:12 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:58580)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1r9NPu-00036W-LR
 for 66961 <at> debbugs.gnu.org; Sat, 02 Dec 2023 05:40:10 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <ludo@HIDDEN>)
 id 1r9NPe-0004FO-Tx; Sat, 02 Dec 2023 05:39:54 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To:
 From; bh=G4l7j17nYBM/41gHsfECD98oi6qjv9zNIvoBL9R0KKo=; b=g4+muwNtXNfVsc0Tr6E+
 IqpAsqaBUMVZU8dJle159ak4Qgg+QM3SPRGwUb19/NG+K1SREyvpffQ46fMgFR7RaNOvx2nVCTrYe
 +1l2K6i7wDENmsf6dtrDzTry/FAoesVNlqomkvOg5j0nRrL2FPOOBZ29qccOm6ltt3vIzDhNZ8x2K
 4draED4TdmMnWTrStvNx5kQbw2vM8wVmucEWRh7QE38mHEl7e44sHU5MxQHP5bij0Ac9fOr00fF8Z
 rvGkmbwnRYDkvUc/QbGOHmgMnCB7PrmGjKqy7XSq+9d4zCsJ2oZ1L3aCxybk8ULVIG80W4dKjSbQr
 T4epPS7X38hh/Q==;
From: Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN>
In-Reply-To: <6a560e37ba23e43d35c0b62c1ee860b4341c263c.1701290895.git.zimon.toutoune@HIDDEN>
 (Simon Tournier's message of "Wed, 29 Nov 2023 21:54:03 +0100")
References: <4be63ddf12bd6143b43e87951e164dc93c585bb8.1699225200.git.zimon.toutoune@HIDDEN>
 <6a560e37ba23e43d35c0b62c1ee860b4341c263c.1701290895.git.zimon.toutoune@HIDDEN>
Date: Sat, 02 Dec 2023 11:39:51 +0100
Message-ID: <87ttp0hoqw.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -2.3 (--)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Hi,

Simon Tournier <zimon.toutoune@HIDDEN> skribis:

> Fixes <https://issues.guix.gnu.org/issue/65979>.
> Reported by Simon Tournier <zimon.toutoune@HIDDEN>
>
> * guix/hash.scm (%vcs-directories): New variable.
> (vcs-file?): Add optional argument for passing VCS kind of the
> file/repository.
> (file-hash*): Adjust accordingly.
> (vcs-exclude?): New procedure and export it.
> * guix/scripts/hash.scm (guix-hash)[file-hash]: Use it.
>
> Change-Id: I8e286c3426ddefd664dc3a471d5a09e309824faa

[...]

> +(define (vcs-exclude? directory)
> +  "Return a procedure excluding content if DIRECTORY contains supported =
VCS."

Nitpick: I would call it =E2=80=98vcs-file-predicate=E2=80=99 for consisten=
cy, with
a docstring along these lines:

  Return a two-argument procedure that returns true for version-control
  metadata directories such as '.git' found in DIRECTORY.

> +  (lambda (file stat)
> +    (not (vcs-file? file stat vcs-directories))))

=E2=80=A6 and thus removing =E2=80=98not=E2=80=99 here

> +            (let ((select? (if (assq-ref opts 'exclude-vcs?)
> +                               (vcs-exclude? file)

=E2=80=A6 and changing the above to (negate (vcs-file-predicate file)).

(=E2=80=9CReturn #t for VCS files=E2=80=9D sounds clearer to me than =E2=80=
=9Creturn true except
for VCS files=E2=80=9D in terms of API design.)

OK with these changes!

Thanks,
Ludo=E2=80=99.




Message sent to guix@HIDDEN, dev@HIDDEN, ludo@HIDDEN, othacehe@HIDDEN, rekado@HIDDEN, zimon.toutoune@HIDDEN, me@HIDDEN, guix-patches@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: [bug#66961] [PATCH v4] scripts: hash: Handle repository with different VCS folders.
References: <4be63ddf12bd6143b43e87951e164dc93c585bb8.1699225200.git.zimon.toutoune@HIDDEN>
In-Reply-To: <4be63ddf12bd6143b43e87951e164dc93c585bb8.1699225200.git.zimon.toutoune@HIDDEN>
Resent-From: Simon Tournier <zimon.toutoune@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: guix@HIDDEN, dev@HIDDEN, ludo@HIDDEN, othacehe@HIDDEN, rekado@HIDDEN, zimon.toutoune@HIDDEN, me@HIDDEN, guix-patches@HIDDEN
Resent-Date: Sat, 02 Dec 2023 13:12:01 +0000
Resent-Message-ID: <handler.66961.B66961.170152271226049 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 66961
X-GNU-PR-Package: guix-patches
X-GNU-PR-Keywords: patch
To: 66961 <at> debbugs.gnu.org
Cc: Simon Tournier <zimon.toutoune@HIDDEN>, Christopher Baines <guix@HIDDEN>, Josselin Poiret <dev@HIDDEN>, Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Ricardo Wurmus <rekado@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN>
X-Debbugs-Original-Xcc: Christopher Baines <guix@HIDDEN>, Josselin Poiret <dev@HIDDEN>, Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Ricardo Wurmus <rekado@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN>
Received: via spool by 66961-submit <at> debbugs.gnu.org id=B66961.170152271226049
          (code B ref 66961); Sat, 02 Dec 2023 13:12:01 +0000
Received: (at 66961) by debbugs.gnu.org; 2 Dec 2023 13:11:52 +0000
Received: from localhost ([127.0.0.1]:56882 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1r9Pmi-0006m4-8a
	for submit <at> debbugs.gnu.org; Sat, 02 Dec 2023 08:11:52 -0500
Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]:40965)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <zimon.toutoune@HIDDEN>) id 1r9Pmf-0006lr-G4
 for 66961 <at> debbugs.gnu.org; Sat, 02 Dec 2023 08:11:50 -0500
Received: by mail-wr1-x430.google.com with SMTP id
 ffacd0b85a97d-3333073c93cso389627f8f.0
 for <66961 <at> debbugs.gnu.org>; Sat, 02 Dec 2023 05:11:40 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1701522694; x=1702127494; darn=debbugs.gnu.org;
 h=content-transfer-encoding:mime-version:message-id:date:subject:cc
 :to:from:from:to:cc:subject:date:message-id:reply-to;
 bh=UbH48YUthrX9cN8LfwXWFFNQxNDvwycFEE3J5XN5i9E=;
 b=SqHibnuP6TzsHYuHNmF1jldoKnugvaWM7QSG7D45Lki9LVB5GKTYSmaonupn2Opci7
 ILI5ADfL9Uxz4SaXjSohnpPhp+sVfeHrexYbnBA4sFEY4ox8xZuC/NH3xx+2hvDxmdNn
 Ykn6b/FZ8udBSrIf8ToOApoYHvAwQaumoXJ3T0NMjronByND3rlDftvhjpDq43ILAIIC
 qCRB7LJWMrPxG4yptRE1HYUVCvdnBOBIofPlEi9FtRoYlTnLDVx3T1y1veVuCXfSTYJ7
 wSf7x8PP517F7Pm93aUY90P3lfTSFj+BNYHozKgHS8RDp14JA9aVRJeyu+rqAE1go43s
 FG2A==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1701522694; x=1702127494;
 h=content-transfer-encoding:mime-version:message-id:date:subject:cc
 :to:from:x-gm-message-state:from:to:cc:subject:date:message-id
 :reply-to;
 bh=UbH48YUthrX9cN8LfwXWFFNQxNDvwycFEE3J5XN5i9E=;
 b=WUfJhqFnj16f3HOP+0KYvXEqFss6rWn9V9MOAtpDqdfpi5pt9ZRyctnp+py6O4Y2wE
 7X1b87Vv9xVLKk40TAcI1WiDDOSAdfVWUp8gFMWcybMgw9Mn/NRLJgCOZzaX+ALo8eup
 NyZDCzrA655uKrfbcjinP3Yn1A+GH3J/d0kiNJIaBuwTixX+6EDuO/P/1YTlvV1WABwd
 FgZjuu3Rw1U983gO3CxwG/mwm8h+tGR7sivOnug9N0y2J0/p5beF3wj+nMMHk3SBI76i
 Yc4/PaIH1gh60OT1ERl1gy8kDjDgsjLZrnyOEFkNJML7X9+iIbnf1nG4lwEey0iSM4Gr
 QX0Q==
X-Gm-Message-State: AOJu0Yxa1TqN1YUBFu1HLvqTcJKgZ4MRaQqQXnenJ0uZpTNcxOhYDUSY
 ++weQKG6jxXdIMjAzhj6WzG3xeEdB2Y=
X-Google-Smtp-Source: AGHT+IHEHSwmE0pl/7WD4NtSJTLmaADpgEk99xFuZTgpLbSv6D+xgjrWckM5/ImYAMH/rWPkKlH09w==
X-Received: by 2002:a5d:64cd:0:b0:333:3044:3e21 with SMTP id
 f13-20020a5d64cd000000b0033330443e21mr4133522wri.6.1701522693904; 
 Sat, 02 Dec 2023 05:11:33 -0800 (PST)
Received: from lili.. ([2a01:e0a:59b:9120:7e06:4c1e:3607:79b6])
 by smtp.gmail.com with ESMTPSA id
 y9-20020adfee09000000b0033335d9dcc5sm2287720wrn.64.2023.12.02.05.11.32
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sat, 02 Dec 2023 05:11:33 -0800 (PST)
From: Simon Tournier <zimon.toutoune@HIDDEN>
Date: Sat,  2 Dec 2023 14:11:20 +0100
Message-ID: <eb84353cf679b77019db31e243354632a24b996e.1701522007.git.zimon.toutoune@HIDDEN>
X-Mailer: git-send-email 2.41.0
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Spam-Score: -0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Fixes <https://issues.guix.gnu.org/issue/65979>.
Reported by Simon Tournier <zimon.toutoune@HIDDEN>

* guix/hash.scm (%vcs-directories): New variable.
(vcs-file?): Add optional argument for passing VCS kind of the
file/repository.
(file-hash*): Adjust accordingly.
(vcs-file-predicate): New procedure and export it.
* guix/scripts/hash.scm (guix-hash)[file-hash]: Use it.

Change-Id: I8e286c3426ddefd664dc3a471d5a09e309824faa
---
 guix/hash.scm         | 35 +++++++++++++++++++++++++++++------
 guix/scripts/hash.scm | 10 +++++-----
 2 files changed, 34 insertions(+), 11 deletions(-)

diff --git a/guix/hash.scm b/guix/hash.scm
index 3cb68e5c44..81f35d63df 100644
--- a/guix/hash.scm
+++ b/guix/hash.scm
@@ -1,6 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2021 Sarah Morgensen <iskarian@HIDDEN>
 ;;; Copyright © 2022 Maxime Devos <maximedevos@HIDDEN>
+;;; Copyright © 2023 Simon Tournier <zimon.toutoune@HIDDEN>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -23,23 +24,45 @@ (define-module (guix hash)
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-11)
   #:export (vcs-file?
+            vcs-file-predicate
             file-hash*))
 
-(define (vcs-file? file stat)
-  "Returns true if FILE is a version control system file."
+(define %vcs-directories
+  ;; Directory used for determining the kind of VCS.
+  (list ".bzr" ".git" ".hg" ".svn" "CVS"))
+
+(define* (vcs-file? file stat
+                    #:optional
+                    (vcs-directories %vcs-directories))
+  "Return true if FILE matches a version control system from the list
+VCSES-DIRECTORIES."
   (case (stat:type stat)
     ((directory)
-     (member (basename file) '(".bzr" ".git" ".hg" ".svn" "CVS")))
+     (member (basename file) vcs-directories))
     ((regular)
-     ;; Git sub-modules have a '.git' file that is a regular text file.
-     (string=? (basename file) ".git"))
+     (if (member ".git" vcs-directories)
+         ;; Git sub-modules have a '.git' file that is a regular text file.
+         (string=? (basename file) ".git")
+         #f))
     (else
      #f)))
 
+(define (vcs-file-predicate directory)
+  "Return a two-argument procedure that returns true when version-control
+metadata directories such as '.git' is found in DIRECTORY."
+  (define vcs-directories
+    (filter (lambda (vcs)
+              (file-exists? (in-vicinity directory vcs)))
+            %vcs-directories))
+
+  (lambda (file stat)
+    (vcs-file? file stat vcs-directories)))
+
 (define* (file-hash* file #:key
                      (algorithm (hash-algorithm sha256))
                      (recursive? 'auto)
-                     (select? (negate vcs-file?)))
+                     (select? (negate (lambda (file stat)
+                                        (vcs-file? file stat)))))
   "Compute the hash of FILE with ALGORITHM.
 
 Symbolic links are only dereferenced if RECURSIVE? is false.
diff --git a/guix/scripts/hash.scm b/guix/scripts/hash.scm
index 7197d3965c..dec037ed3f 100644
--- a/guix/scripts/hash.scm
+++ b/guix/scripts/hash.scm
@@ -3,7 +3,7 @@
 ;;; Copyright © 2013 Nikita Karetnikov <nikita@HIDDEN>
 ;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@HIDDEN>
 ;;; Copyright © 2018 Tim Gesthuizen <tim.gesthuizen@HIDDEN>
-;;; Copyright © 2021 Simon Tournier <zimon.toutoune@HIDDEN>
+;;; Copyright © 2021, 2023 Simon Tournier <zimon.toutoune@HIDDEN>
 ;;; Copyright © 2021 Sarah Morgensen <iskarian@HIDDEN>
 ;;;
 ;;; This file is part of GNU Guix.
@@ -181,9 +181,6 @@ (define-command (guix-hash . args)
                             (_ #f))
                            (reverse opts)))
          (fmt  (assq-ref opts 'format))
-         (select? (if (assq-ref opts 'exclude-vcs?)
-                      (negate vcs-file?)
-                      (const #t)))
          (algorithm (assoc-ref opts 'hash-algorithm))
          (serializer (assoc-ref opts 'serializer)))
 
@@ -193,7 +190,10 @@ (define-command (guix-hash . args)
       (catch 'system-error
         (lambda _
           (with-error-handling
-            (serializer file algorithm select?)))
+            (let ((select? (if (assq-ref opts 'exclude-vcs?)
+                               (negate (vcs-file-predicate file))
+                               (const #t))))
+              (serializer file algorithm select?))))
         (lambda args
           (leave (G_ "~a ~a~%")
                  file

base-commit: aeb494322ca9dec4a4d66a7d063239c8536bd538
-- 
2.41.0





Message sent to guix-patches@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: [bug#66961] [PATCH v3] scripts: hash: Handle repository with different VCS folders.
Resent-From: Simon Tournier <zimon.toutoune@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: guix-patches@HIDDEN
Resent-Date: Sat, 02 Dec 2023 14:01:01 +0000
Resent-Message-ID: <handler.66961.B66961.170152560931252 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 66961
X-GNU-PR-Package: guix-patches
X-GNU-PR-Keywords: patch
To: Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN>
Cc: Josselin Poiret <dev@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN>, 66961 <at> debbugs.gnu.org, Ricardo Wurmus <rekado@HIDDEN>, Christopher Baines <guix@HIDDEN>
Received: via spool by 66961-submit <at> debbugs.gnu.org id=B66961.170152560931252
          (code B ref 66961); Sat, 02 Dec 2023 14:01:01 +0000
Received: (at 66961) by debbugs.gnu.org; 2 Dec 2023 14:00:09 +0000
Received: from localhost ([127.0.0.1]:56938 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1r9QXQ-00087z-R4
	for submit <at> debbugs.gnu.org; Sat, 02 Dec 2023 09:00:09 -0500
Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]:39185)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <zimon.toutoune@HIDDEN>) id 1r9QXO-00085o-N8
 for 66961 <at> debbugs.gnu.org; Sat, 02 Dec 2023 09:00:07 -0500
Received: by mail-wm1-x32a.google.com with SMTP id
 5b1f17b1804b1-40b4ff0f254so4239225e9.1
 for <66961 <at> debbugs.gnu.org>; Sat, 02 Dec 2023 05:59:57 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1701525591; x=1702130391; darn=debbugs.gnu.org;
 h=content-transfer-encoding:mime-version:message-id:date:references
 :in-reply-to:subject:cc:to:from:from:to:cc:subject:date:message-id
 :reply-to; bh=myHxxtlW3lKv8Nk4JtGBS3Mvff3WMeGdAGXexcVKZF0=;
 b=MWCzyxhPglnWA7k88pXBu4j8m67g2Pw5JRf0+5vLgfEen7MJ7WiJiOD7OtCdgc2oGG
 K7dq9qfidMQKaqxt+VAr7X0bkFcztccpTT+0sOIEj5HL9kOG5wpqcF2PeWiOUzqLTuxv
 +lsJuB85bx6CKvfe3FgMNyMCWZAp+4YWmrJ9ekPbYm1h5qpejFmDsGG7sdi2YSs/WCrh
 JIbHnoz97Me1FJ1GQWrap1M3R8XfkQBu0bE6gjiDkQwFMNSVfM+BfbItStRXPThUDDqE
 bny29U5AOJPy9tEPhHAIZzvunjhsjjHNEj5rkZdQfsd0z2RsOhnqgwDzYeA8DvWt6g9B
 Lviw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1701525591; x=1702130391;
 h=content-transfer-encoding:mime-version:message-id:date:references
 :in-reply-to:subject:cc:to:from:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=myHxxtlW3lKv8Nk4JtGBS3Mvff3WMeGdAGXexcVKZF0=;
 b=bq7uSEefz9wV+UciSCWDxm4NV02AbaQat5uGYg21SDZWEsO3mC/vBN/VAdhlruq1cx
 4hJZqDtqRQ4un9VsRyF8s8Id3DF72Vn2TqQiykOPi5NkoD7st01eDX1Uy7nCjYHzYOzW
 ebkLG7HW7Hd/qP4pzLIIROk3OyGE9xYhmEqD0PvPW3CxxgTI0gxov+0X5YVfrDiJt4ZS
 fWo1EaLVYyB7GaAHPFGbUCHhnjo2eJewTucJCX+TbYAhgtZkvJWFI0NtgxmYl0FpegpJ
 muYIgWu2eIDs51Ce3yc4QwTMXXgwmazLDWALdfM+/RSE4B6FZOV6VPdP95weaUaV6rES
 mNug==
X-Gm-Message-State: AOJu0Ywu/HuJosBfwKFZuZdfwNd6OhJD50++mGGF+4xVEJQyUwq0UBoG
 0kzkRzwPig1coTWuxw9PAfI=
X-Google-Smtp-Source: AGHT+IFC1u+k+9A/rt4ZArtZaczk3MK60BIKmNCtBRThffadqYy3kc1vJWMSPWJnIKJoFUgjkOaixw==
X-Received: by 2002:a05:600c:1c97:b0:3fe:d637:7b25 with SMTP id
 k23-20020a05600c1c9700b003fed6377b25mr5582744wms.0.1701525591278; 
 Sat, 02 Dec 2023 05:59:51 -0800 (PST)
Received: from lili ([2a01:e0a:59b:9120:7e06:4c1e:3607:79b6])
 by smtp.gmail.com with ESMTPSA id
 m8-20020a05600c4f4800b0040b37f107c4sm8810641wmq.16.2023.12.02.05.59.49
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sat, 02 Dec 2023 05:59:50 -0800 (PST)
From: Simon Tournier <zimon.toutoune@HIDDEN>
In-Reply-To: <87ttp0hoqw.fsf@HIDDEN>
References: <4be63ddf12bd6143b43e87951e164dc93c585bb8.1699225200.git.zimon.toutoune@HIDDEN>
 <6a560e37ba23e43d35c0b62c1ee860b4341c263c.1701290895.git.zimon.toutoune@HIDDEN>
 <87ttp0hoqw.fsf@HIDDEN>
Date: Sat, 02 Dec 2023 14:10:24 +0100
Message-ID: <87o7f8rbr3.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Hi,

On sam., 02 d=C3=A9c. 2023 at 11:39, Ludovic Court=C3=A8s <ludo@HIDDEN> wr=
ote:

> Nitpick: I would call it =E2=80=98vcs-file-predicate=E2=80=99 for consist=
ency,

Hum, I thought the convention for =E2=80=99predicate=E2=80=99 was ending by=
 =E2=80=99?=E2=80=99.
Therefore, personally I do not find this name consistent.  Anyway=E2=80=A6

>                                                                with
> a docstring along these lines:
>
>   Return a two-argument procedure that returns true for version-control
>   metadata directories such as '.git' found in DIRECTORY.

=E2=80=A6did that way in v4.

Thanks for your comments.


Cheers,
simon




Message sent to guix-patches@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: [bug#66961] [PATCH v4] scripts: hash: Handle repository with different VCS folders.
Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: guix-patches@HIDDEN
Resent-Date: Fri, 22 Dec 2023 16:20:02 +0000
Resent-Message-ID: <handler.66961.B66961.170326196920106 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 66961
X-GNU-PR-Package: guix-patches
X-GNU-PR-Keywords: patch
To: Simon Tournier <zimon.toutoune@HIDDEN>
Cc: Josselin Poiret <dev@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN>, 66961 <at> debbugs.gnu.org, Ricardo Wurmus <rekado@HIDDEN>, Christopher Baines <guix@HIDDEN>
Received: via spool by 66961-submit <at> debbugs.gnu.org id=B66961.170326196920106
          (code B ref 66961); Fri, 22 Dec 2023 16:20:02 +0000
Received: (at 66961) by debbugs.gnu.org; 22 Dec 2023 16:19:29 +0000
Received: from localhost ([127.0.0.1]:47672 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rGiFE-0005EE-It
	for submit <at> debbugs.gnu.org; Fri, 22 Dec 2023 11:19:28 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:35630)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1rGiFC-0005Dy-Q2
 for 66961 <at> debbugs.gnu.org; Fri, 22 Dec 2023 11:19:27 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <ludo@HIDDEN>)
 id 1rGiF0-00085r-Lo; Fri, 22 Dec 2023 11:19:14 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To:
 From; bh=n+OMQybasgoyoFaS6ufvVXWUhyx+gFTYgBSQJqQnB6A=; b=ST19Va0AmGMTygTxz/Ky
 PgQDreJTjMMx1epS7zo2iTKAXHAfGUad0gJkXZnV1Iqg//Vk3TK7pxrlNpydJzow6o2RGbjRK0Glb
 ELo6bVXGIYhtOK7iTKnkkwXCnQrssbfl1gF8HejsChtWcPdPqf0P/bS9HJbtCurnkkKL+2QSi2k/w
 yPWrnCIOjpzHzqitXSTeXhGO0SVae2gxS6+bj+oxhbaZUymGuht0eZ9UncQhAUnnK4hSkKyNCyu2s
 p3CO/m3r/wdRgHegUC+x8yvjDa62M0g4/qYQsRMdFQhqQ/UtzuDyJ32O6sDTT6FFsKMpfC+a4NX3B
 XTvrOoaZpDF2fQ==;
From: Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN>
In-Reply-To: <eb84353cf679b77019db31e243354632a24b996e.1701522007.git.zimon.toutoune@HIDDEN>
 (Simon Tournier's message of "Sat, 2 Dec 2023 14:11:20 +0100")
References: <4be63ddf12bd6143b43e87951e164dc93c585bb8.1699225200.git.zimon.toutoune@HIDDEN>
 <eb84353cf679b77019db31e243354632a24b996e.1701522007.git.zimon.toutoune@HIDDEN>
Date: Fri, 22 Dec 2023 17:19:12 +0100
Message-ID: <871qbeb473.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -2.3 (--)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Hi,

Simon Tournier <zimon.toutoune@HIDDEN> skribis:

> Fixes <https://issues.guix.gnu.org/issue/65979>.
> Reported by Simon Tournier <zimon.toutoune@HIDDEN>
>
> * guix/hash.scm (%vcs-directories): New variable.
> (vcs-file?): Add optional argument for passing VCS kind of the
> file/repository.
> (file-hash*): Adjust accordingly.
> (vcs-file-predicate): New procedure and export it.
> * guix/scripts/hash.scm (guix-hash)[file-hash]: Use it.
>
> Change-Id: I8e286c3426ddefd664dc3a471d5a09e309824faa

Sorry for the long delay=E2=80=94LGTM!

Thanks,
Ludo=E2=80=99.





Last modified: Sat, 20 Jan 2024 12:30:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.