mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2025-01-27 13:09:23 -05:00
import: crate: Simplify find-crate-version.
* guix/import/crate.scm (find-crate-version): Reuse nonyanked-crate-versions, max-crate-version-of-semver. Change-Id: I976a3b5a397f0d6a7d723804a98356544bfc7da3
This commit is contained in:
parent
5ce1512b0f
commit
8520f00d69
1 changed files with 8 additions and 20 deletions
|
@ -322,26 +322,14 @@ (define (find-package-version name range)
|
|||
;; 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,
|
||||
|
|
Loading…
Reference in a new issue