guix-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#66421: [PATCH] guix: import: Don't import yanked rust crates.


From: Efraim Flashner
Subject: bug#66421: [PATCH] guix: import: Don't import yanked rust crates.
Date: Sun, 22 Oct 2023 16:57:54 +0300

On Wed, Oct 18, 2023 at 10:24:57PM -0400, Maxim Cournoyer wrote:
> Hi Efraim,
> 
> Efraim Flashner <efraim@flashner.co.il> writes:
> 
> > * guix/import/crate.scm (<crate-version>): Add yanked? field.
> > (crate->guix-package)[find-crate-version]: Remove versions which have
> > been yanked.
> > * tests/crate.scm: Adjust tests for new yanked? field.
> > ---
> >
> > Before this patch `guix import core-foundation-sys` would give 0.8.4
> > (the listed max version), `guix import core-foundation-sys@0.8` would
> > give 0.8.5 (which was yanked but was higher than 0.8.4). Similarly,
> > before `guix import core-foundation-sys@0.7` gave 0.7.2 and after 0.7.0.
> >
> >  guix/import/crate.scm |  7 ++++++-
> >  tests/crate.scm       | 40 +++++++++++++++++++++++++++-------------
> >  2 files changed, 33 insertions(+), 14 deletions(-)
> >
> > diff --git a/guix/import/crate.scm b/guix/import/crate.scm
> > index 6e10ebb5d4..a7eafb023e 100644
> > --- a/guix/import/crate.scm
> > +++ b/guix/import/crate.scm
> > @@ -5,6 +5,7 @@
> >  ;;; Copyright © 2021 Nicolas Goaziou <mail@nicolasgoaziou.fr>
> >  ;;; Copyright © 2022 Hartmut Goebel <h.goebel@crazy-compilers.com>
> >  ;;; Copyright © 2023 Simon Tournier <zimon.toutoune@gmail.com>
> > +;;; Copyright © 2023 Efraim Flashner <efraim@flashner.co.il>
> >  ;;;
> >  ;;; This file is part of GNU Guix.
> >  ;;;
> > @@ -82,6 +83,7 @@ (define-json-mapping <crate-version> make-crate-version 
> > crate-version?
> >                   (match-lambda
> >                     ('null #f)
> >                     ((? string? str) str)))
> > +  (yanked?       crate-version-yanked? "yanked")  ;boolean
> >    (links         crate-version-links))            ;alist
> >  
> >  ;; Crate dependency.  Each dependency (each edge in the graph) is 
> > annotated as
> > @@ -256,12 +258,15 @@ (define* (crate->guix-package crate-name #:key 
> > version include-dev-deps?
> >             (semver->string (last versions)))))
> >  
> >    ;; find the highest version of a crate that fulfills the semver <range>
> > +  ;; and hasn't been yanked
> 
> While touching this comment, it'd be nice to turn add punctuation
> (capitalize the first letter and add a period).

Done

> >    (define (find-crate-version crate range)
> >      (let* ((semver-range (string->semver-range range))
> >             (versions
> >              (sort
> >               (filter (lambda (entry)
> > -                       (semver-range-contains? semver-range (first entry)))
> > +                       (and
> > +                         (not (crate-version-yanked? (second entry)))
> > +                         (semver-range-contains? semver-range (first 
> > entry))))
> >                       (map (lambda (ver)
> >                              (list (string->semver (crate-version-number 
> > ver))
> >                                    ver))
> 
> LGTM.  Related, but not in scope, could be to rewrite the above using a
> match-lambda instead of accessing the entry items via first second.

This I'm going to have to spend some more time on, I haven't used
match-lambda much.

-- 
Efraim Flashner   <efraim@flashner.co.il>   רנשלפ םירפא
GPG key = A28B F40C 3E55 1372 662D  14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]