summaryrefslogtreecommitdiff
path: root/guix/import/github.scm
diff options
context:
space:
mode:
authorMarius Bakke <mbakke@fastmail.com>2019-05-25 00:25:15 +0200
committerMarius Bakke <mbakke@fastmail.com>2019-05-25 00:25:15 +0200
commit57df83e07d4b5e78d9a54c1a88d05b4a9ed65714 (patch)
tree76684e63965e9ad6e37d9d45bc3159e6c9782cd0 /guix/import/github.scm
parent43d9ed7792808638eabb43aa6133f1d6186c520b (diff)
parent136b7d81f0eb713783e9ea7cf7f260a2b6252dfd (diff)
downloadguix-patches-57df83e07d4b5e78d9a54c1a88d05b4a9ed65714.tar
guix-patches-57df83e07d4b5e78d9a54c1a88d05b4a9ed65714.tar.gz
Merge branch 'staging' into core-updates
Diffstat (limited to 'guix/import/github.scm')
-rw-r--r--guix/import/github.scm56
1 files changed, 30 insertions, 26 deletions
diff --git a/guix/import/github.scm b/guix/import/github.scm
index 4d12339204..cdac70420a 100644
--- a/guix/import/github.scm
+++ b/guix/import/github.scm
@@ -174,6 +174,29 @@ the package e.g. 'bedtools2'. Return #f if there is no releases"
(define (pre-release? x)
(hash-ref x "prerelease"))
+ (define (release->version release)
+ (let ((tag (or (hash-ref release "tag_name") ;a "release"
+ (hash-ref release "name"))) ;a tag
+ (name-length (string-length package-name)))
+ (cond
+ ;; some tags include the name of the package e.g. "fdupes-1.51"
+ ;; so remove these
+ ((and (< name-length (string-length tag))
+ (string=? (string-append package-name "-")
+ (substring tag 0 (+ name-length 1))))
+ (substring tag (+ name-length 1)))
+ ;; some tags start with a "v" e.g. "v0.25.0"
+ ;; where some are just the version number
+ ((string-prefix? "v" tag)
+ (substring tag 1))
+ ;; Finally, reject tags that don't start with a digit:
+ ;; they may not represent a release.
+ ((and (not (string-null? tag))
+ (char-set-contains? char-set:digit
+ (string-ref tag 0)))
+ tag)
+ (else #f))))
+
(let* ((json (fetch-releases-or-tags url)))
(if (eq? json #f)
(if (%github-token)
@@ -183,32 +206,13 @@ API when using a GitHub token")
API. This may be fixed by using an access token and setting the environment
variable GUIX_GITHUB_TOKEN, for instance one procured from
https://github.com/settings/tokens"))
- (any
- (lambda (release)
- (let ((tag (or (hash-ref release "tag_name") ;a "release"
- (hash-ref release "name"))) ;a tag
- (name-length (string-length package-name)))
- (cond
- ;; some tags include the name of the package e.g. "fdupes-1.51"
- ;; so remove these
- ((and (< name-length (string-length tag))
- (string=? (string-append package-name "-")
- (substring tag 0 (+ name-length 1))))
- (substring tag (+ name-length 1)))
- ;; some tags start with a "v" e.g. "v0.25.0"
- ;; where some are just the version number
- ((string-prefix? "v" tag)
- (substring tag 1))
- ;; Finally, reject tags that don't start with a digit:
- ;; they may not represent a release.
- ((and (not (string-null? tag))
- (char-set-contains? char-set:digit
- (string-ref tag 0)))
- tag)
- (else #f))))
- (match (remove pre-release? json)
- (() json) ; keep everything
- (releases releases))))))
+ (match (sort (filter-map release->version
+ (match (remove pre-release? json)
+ (() json) ; keep everything
+ (releases releases)))
+ version>?)
+ ((latest-release . _) latest-release)
+ (() #f)))))
(define (latest-release pkg)
"Return an <upstream-source> for the latest release of PKG."