From: Arun Isaac <arunisaac@systemreboot.net>
To: 35684@debbugs.gnu.org
Subject: [bug#35684] import: github: Sort releases before picking the latest one.
Date: Sat, 11 May 2019 16:53:21 +0530 [thread overview]
Message-ID: <cu7h8a19qvq.fsf@systemreboot.net> (raw)
[-- Attachment #1.1: Type: text/plain, Size: 138 bytes --]
Prior to this, for some packages (e.g., osc in (gnu packages
build-tools)), `guix refresh' could not find the latest version
correctly.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-import-github-Sort-releases-before-picking-the-lates.patch --]
[-- Type: text/x-patch, Size: 3681 bytes --]
From 33f42ea8a33c6e502062708336a5ab8be871c92b Mon Sep 17 00:00:00 2001
From: Arun Isaac <arunisaac@systemreboot.net>
Date: Sat, 11 May 2019 16:40:38 +0530
Subject: [PATCH] import: github: Sort releases before picking the latest one.
* guix/import/github.scm (latest-released-version): Sort releases before
picking the first one as the latest.
---
guix/import/github.scm | 55 ++++++++++++++++++++++--------------------
1 file changed, 29 insertions(+), 26 deletions(-)
diff --git a/guix/import/github.scm b/guix/import/github.scm
index 4d12339204..a8af318bc8 100644
--- a/guix/import/github.scm
+++ b/guix/import/github.scm
@@ -183,32 +183,35 @@ 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))))))
+ (first
+ (sort
+ (filter-map
+ (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)))
+ version>?)))))
(define (latest-release pkg)
"Return an <upstream-source> for the latest release of PKG."
--
2.21.0
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]
next reply other threads:[~2019-05-11 11:24 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-11 11:23 Arun Isaac [this message]
2019-05-12 21:47 ` [bug#35684] import: github: Sort releases before picking the latest one Ludovic Courtès
2019-05-13 8:08 ` Arun Isaac
2019-05-13 13:42 ` Ludovic Courtès
2019-05-14 10:19 ` Arun Isaac
2019-05-14 20:59 ` Ludovic Courtès
2019-05-15 8:25 ` bug#35684: " Arun Isaac
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
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cu7h8a19qvq.fsf@systemreboot.net \
--to=arunisaac@systemreboot.net \
--cc=35684@debbugs.gnu.org \
/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 public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).