Subject: [bug#66961] [PATCH v3] scripts: hash: Handle repository with different VCS folders.

From: Ludovic Courtès <[email-masked]>
Date: Sat, 02 Dec 2023 11:39:51 +0100

Hi,

Simon Tournier <[email-masked]> skribis:

> Fixes <https://issues.guix.gnu.org/issue/65979>.
> Reported by Simon Tournier <[email-masked]>
>
> * 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 ‘vcs-file-predicate’ for consistency, 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))))

… and thus removing ‘not’ here

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

… and changing the above to (negate (vcs-file-predicate file)).

(“Return #t for VCS files” sounds clearer to me than “return true except
for VCS files” in terms of API design.)

OK with these changes!

Thanks,
Ludo’.