GNU bug report logs - #35684
import: github: Sort releases before picking the latest one.

Previous Next

Package: guix-patches;

Reported by: Arun Isaac <arunisaac <at> systemreboot.net>

Date: Sat, 11 May 2019 11:24:02 UTC

Severity: normal

Done: Arun Isaac <arunisaac <at> systemreboot.net>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Arun Isaac <arunisaac <at> systemreboot.net>
Cc: tracker <at> debbugs.gnu.org
Subject: bug#35684: closed (import: github: Sort releases before picking
 the latest one.)
Date: Wed, 15 May 2019 08:26:02 +0000
[Message part 1 (text/plain, inline)]
Your message dated Wed, 15 May 2019 13:55:35 +0530
with message-id <cu77eas86ps.fsf <at> systemreboot.net>
and subject line Re: [bug#35684] import: github: Sort releases before picking the latest one.
has caused the debbugs.gnu.org bug report #35684,
regarding import: github: Sort releases before picking the latest one.
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)


-- 
35684: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=35684
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Arun Isaac <arunisaac <at> systemreboot.net>
To: guix-patches <at> gnu.org
Subject: import: github: Sort releases before picking the latest one.
Date: Sat, 11 May 2019 16:53:21 +0530
[Message part 3 (text/plain, inline)]
Prior to this, for some packages (e.g., osc in (gnu packages
build-tools)), `guix refresh' could not find the latest version
correctly.

[0001-import-github-Sort-releases-before-picking-the-lates.patch (text/x-patch, inline)]
From 33f42ea8a33c6e502062708336a5ab8be871c92b Mon Sep 17 00:00:00 2001
From: Arun Isaac <arunisaac <at> 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

[signature.asc (application/pgp-signature, inline)]
[Message part 6 (message/rfc822, inline)]
From: Arun Isaac <arunisaac <at> systemreboot.net>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 35684-done <at> debbugs.gnu.org
Subject: Re: [bug#35684] import: github: Sort releases before picking the
 latest one.
Date: Wed, 15 May 2019 13:55:35 +0530
[Message part 7 (text/plain, inline)]
Pushed to master, thanks!
[signature.asc (application/pgp-signature, inline)]

This bug report was last modified 6 years and 3 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.