[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug#57460] [PATCH v3 10/18] import: github: Allow updating to a specifi
From: |
Hartmut Goebel |
Subject: |
[bug#57460] [PATCH v3 10/18] import: github: Allow updating to a specific version. |
Date: |
Tue, 20 Dec 2022 10:34:15 +0100 |
* guix/import/github.scm (latest-released-version): Add #:version argument.
If version is given, try to find the respective release.
(latest-releease) Rename to 'import-release', add #:version argument
and pass it on to 'latest-released-version'.
---
guix/import/github.scm | 36 ++++++++++++++++++++++++------------
1 file changed, 24 insertions(+), 12 deletions(-)
diff --git a/guix/import/github.scm b/guix/import/github.scm
index ac6ef06eda..a1bda5ec43 100644
--- a/guix/import/github.scm
+++ b/guix/import/github.scm
@@ -249,11 +249,13 @@ Alternatively, you can wait until your rate limit is
reset, or use the
#:headers headers)))
(x x)))))))))
-(define (latest-released-version url package-name)
+(define* (latest-released-version url package-name #:key (version #f))
"Return the newest released version and its tag given a string URL like
'https://github.com/arq5x/bedtools2/archive/v2.24.0.tar.gz' and the name of
the package e.g. 'bedtools2'. Return #f (two values) if there are no
-releases."
+releases.
+
+Optionally include a VERSION string to fetch a specific version."
(define (pre-release? x)
(assoc-ref x "prerelease"))
@@ -290,16 +292,25 @@ releases."
(match (and=> (fetch-releases-or-tags url) vector->list)
(#f (values #f #f))
(json
- (match (sort (filter-map release->version
- (match (remove pre-release? json)
- (() json) ; keep everything
- (releases releases)))
- (lambda (x y) (version>? (car x) (car y))))
+ (let ((releases (filter-map release->version
+ (match (remove pre-release? json)
+ (() json) ; keep everything
+ (releases releases)))))
+ (match (if version
+ ;; Find matching release version.
+ (filter (match-lambda
+ ((candidate-version . tag)
+ (string=? version candidate-version)))
+ releases)
+ ;; Sort releases descending.
+ (sort releases
+ (lambda (x y) (version>? (car x) (car y)))))
(((latest-version . tag) . _) (values latest-version tag))
- (() (values #f #f))))))
+ (() (values #f #f)))))))
-(define (latest-release pkg)
- "Return an <upstream-source> for the latest release of PKG."
+(define* (import-release pkg #:key (version #f))
+ "Return an <upstream-source> for the latest release of PKG.
+Optionally include a VERSION string to fetch a specific version."
(define (github-uri uri)
(match uri
((? string? url)
@@ -313,7 +324,8 @@ releases."
(source-uri (github-uri original-uri))
(name (package-name pkg))
(newest-version version-tag
- (latest-released-version source-uri name)))
+ (latest-released-version source-uri name
+ #:version version)))
(if newest-version
(upstream-source
(package name)
@@ -330,6 +342,6 @@ releases."
(name 'github)
(description "Updater for GitHub packages")
(pred github-package?)
- (import latest-release)))
+ (import import-release)))
--
2.30.6
- [bug#57460] [PATCH v3 06/18] import: crate: Allow updating to a specific version., (continued)
- [bug#57460] [PATCH v3 06/18] import: crate: Allow updating to a specific version., Hartmut Goebel, 2022/12/20
- [bug#57460] [PATCH v3 02/18] import: cpan: Remove unused exports., Hartmut Goebel, 2022/12/20
- [bug#57460] [PATCH v3 11/18] import: gnome: Allow updating to a specific version., Hartmut Goebel, 2022/12/20
- [bug#57460] [PATCH v3 08/18] import: gem: Allow updating to a specific version., Hartmut Goebel, 2022/12/20
- [bug#57460] [PATCH v3 05/18] gnu-maintenance: Allow updating to a specific version., Hartmut Goebel, 2022/12/20
- [bug#57460] [PATCH v3 13/18] import: kde: Allow updating to a specific version., Hartmut Goebel, 2022/12/20
- [bug#57460] [PATCH v3 17/18] upstream: Allow updating to a specific version., Hartmut Goebel, 2022/12/20
- [bug#57460] [PATCH v3 18/18] doc: Describe how to update to a specific version., Hartmut Goebel, 2022/12/20
- [bug#57460] [PATCH v3 03/18] import: Issue error-message if version is given., Hartmut Goebel, 2022/12/20
- [bug#57460] [PATCH v3 10/18] import: github: Allow updating to a specific version.,
Hartmut Goebel <=
- [bug#57460] [PATCH v3 12/18] import: hexpm: Allow updating to a specific version., Hartmut Goebel, 2022/12/20
- [bug#57460] [PATCH v3 09/18] import: git: Allow updating to a specific version., Hartmut Goebel, 2022/12/20
- [bug#57460] [PATCH v3 14/18] import: launchpad: Allow updating to a specific version., Hartmut Goebel, 2022/12/20
- [bug#57460] [PATCH v3 16/18] refresh: Allow updating to a specific version., Hartmut Goebel, 2022/12/20
- [bug#57460] [PATCH v3 15/18] import: pypi: Allow updating to a specific version., Hartmut Goebel, 2022/12/20
- [bug#57460] [PATCH v3 04/18] import: sourceforge: Issue error-message if version is given., Hartmut Goebel, 2022/12/20
- [bug#57460] [PATCH 00/19] Refresh to specific version, Ludovic Courtès, 2022/12/23