[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug#66961] [PATCH] scripts: hash: Handle repository with different VCS
From: |
Ludovic Courtès |
Subject: |
[bug#66961] [PATCH] scripts: hash: Handle repository with different VCS folders. |
Date: |
Tue, 14 Nov 2023 14:44:52 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
Hi!
Simon Tournier <zimon.toutoune@gmail.com> skribis:
> Fixes <https://issues.guix.gnu.org/issue/65979>.
> Reported by Simon Tournier <zimon.toutoune@gmail.com>
>
> * 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
[...]
> +(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."
How about ‘vcs-directories’ rather than ‘vcses’?
Also, you can add:
(define %known-vcs-directories
'(".bzr" …))
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’t stat these things when
‘exclude-vcs?’ is #false.)
Thanks,
Ludo’.