From: Efraim Flashner <efraim@flashner.co.il>
To: 68346@debbugs.gnu.org
Cc: David Elsing <david.elsing@posteo.net>,
Jaeme Sifat <jaeme@runbox.com>,
Efraim Flashner <efraim@flashner.co.il>,
Efraim Flashner <efraim@flashner.co.il>
Subject: [bug#68346] [PATCH 2/2] import: crate: Simplify find-crate-version.
Date: Tue, 9 Jan 2024 15:07:37 +0200 [thread overview]
Message-ID: <3caa53187f36dbc95f7b9ef982632cc284981e28.1704805408.git.efraim@flashner.co.il> (raw)
In-Reply-To: <cover.1704805408.git.efraim@flashner.co.il>
* guix/import/crate.scm (find-crate-version): Reuse
nonyanked-crate-versions, max-crate-version-of-semver.
Change-Id: I976a3b5a397f0d6a7d723804a98356544bfc7da3
---
guix/import/crate.scm | 28 ++++++++--------------------
1 file changed, 8 insertions(+), 20 deletions(-)
diff --git a/guix/import/crate.scm b/guix/import/crate.scm
index 43f80f3fb7..ba2bc1573e 100644
--- a/guix/import/crate.scm
+++ b/guix/import/crate.scm
@@ -310,26 +310,14 @@ (define* (crate->guix-package
;; If no matching non-yanked version has been found and allow-yanked? is #t,
;; also consider yanked packages.
(define (find-crate-version crate range)
- (let* ((semver-range (string->semver-range range))
- (versions
- (sort
- (filter (lambda (entry)
- (and
- (or allow-yanked?
- (not (crate-version-yanked? (second entry))))
- (semver-range-contains? semver-range (first entry))))
- (map (lambda (ver)
- (list (string->semver (crate-version-number ver))
- ver))
- (crate-versions crate)))
- (match-lambda* (((semver ver) ...)
- (match-let (((yanked1 yanked2)
- (map crate-version-yanked? ver)))
- (or (and yanked1 (not yanked2))
- (and (eq? yanked1 yanked2)
- (apply semver<? semver)))))))))
- (and (not (null-list? versions))
- (second (last versions)))))
+ (let ((semver-range (string->semver-range range))
+ (versions (nonyanked-crate-versions crate)))
+ (or (and (not (null-list? versions))
+ (max-crate-version-of-semver semver-range versions))
+ (and allow-yanked?
+ (not (null-list? (crate-versions crate)))
+ (max-crate-version-of-semver semver-range
+ (crate-versions crate))))))
;; If no non-yanked existing package version was found, check the upstream
;; versions. If a non-yanked upsteam version exists, use it instead,
--
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
next prev parent reply other threads:[~2024-01-09 13:09 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-09 13:05 [bug#68346] [PATCH 0/2] semver aware cargo refresh Efraim Flashner
2024-01-09 13:07 ` [bug#68346] [PATCH 1/2] import: crate: Update to latest semver version Efraim Flashner
2024-01-09 13:07 ` Efraim Flashner [this message]
2024-01-14 12:54 ` [bug#68346] [PATCH 0/2] semver aware cargo refresh David Elsing
2024-01-16 12:26 ` bug#68346: " Efraim Flashner
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3caa53187f36dbc95f7b9ef982632cc284981e28.1704805408.git.efraim@flashner.co.il \
--to=efraim@flashner.co.il \
--cc=68346@debbugs.gnu.org \
--cc=david.elsing@posteo.net \
--cc=jaeme@runbox.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 external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.