unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: "Ludovic Courtès" <ludo@gnu.org>
To: Simon Tournier <zimon.toutoune@gmail.com>
Cc: Josselin Poiret <dev@jpoiret.xyz>,
	Mathieu Othacehe <othacehe@gnu.org>,
	Tobias Geerinckx-Rice <me@tobias.gr>,
	66961@debbugs.gnu.org, Ricardo Wurmus <rekado@elephly.net>,
	Christopher Baines <guix@cbaines.net>
Subject: [bug#66961] [PATCH] scripts: hash: Handle repository with different VCS folders.
Date: Tue, 14 Nov 2023 14:44:52 +0100	[thread overview]
Message-ID: <87zfzg8n57.fsf@gnu.org> (raw)
In-Reply-To: <4be63ddf12bd6143b43e87951e164dc93c585bb8.1699225200.git.zimon.toutoune@gmail.com> (Simon Tournier's message of "Mon, 6 Nov 2023 00:00:55 +0100")

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’.




  reply	other threads:[~2023-11-14 13:45 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-05 23:00 [bug#66961] [PATCH] scripts: hash: Handle repository with different VCS folders Simon Tournier
2023-11-14 13:44 ` Ludovic Courtès [this message]
2023-11-29 20:36   ` Simon Tournier
2023-11-29 20:52     ` Simon Tournier
2023-11-29 20:31 ` [bug#66961] [PATCH v2] " Simon Tournier
2023-11-29 20:54 ` [bug#66961] [PATCH v3] " Simon Tournier
2023-12-02 10:39   ` Ludovic Courtès
2023-12-02 13:10     ` Simon Tournier
2023-12-02 13:11 ` [bug#66961] [PATCH v4] " Simon Tournier
2023-12-22 16:19   ` Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87zfzg8n57.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=66961@debbugs.gnu.org \
    --cc=dev@jpoiret.xyz \
    --cc=guix@cbaines.net \
    --cc=me@tobias.gr \
    --cc=othacehe@gnu.org \
    --cc=rekado@elephly.net \
    --cc=zimon.toutoune@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).