[bug#35684] import: github: Sort releases before picking the latestone.
diff mbox series

Message ID cu7y3398hk3.fsf@systemreboot.net
State New
Headers show
Series
  • [bug#35684] import: github: Sort releases before picking the latestone.
Related show

Checks

Context Check Description
cbaines/applying patch fail Apply failed

Commit Message

Arun Isaac May 14, 2019, 10:19 a.m. UTC
> If you don’t mind, you can make it two patches for clarity (one that
> defines ‘release->version’, and one that adds the call to ‘sort’)

Sure, pleae find attached.

Patch
diff mbox series

From 8192712f8108d0abcd527ff6b16af073c453b780 Mon Sep 17 00:00:00 2001
From: Arun Isaac <arunisaac@systemreboot.net>
Date: Tue, 14 May 2019 15:46:19 +0530
Subject: [PATCH 2/2] 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 | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/guix/import/github.scm b/guix/import/github.scm
index 5f4d9c7267..cdac70420a 100644
--- a/guix/import/github.scm
+++ b/guix/import/github.scm
@@ -206,10 +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 release->version
-             (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."
-- 
2.21.0