guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

06/06: import: github: Filter out tags that don't look like version numb


From: Ludovic Courtès
Subject: 06/06: import: github: Filter out tags that don't look like version numbers.
Date: Mon, 20 Aug 2018 10:32:28 -0400 (EDT)

civodul pushed a commit to branch master
in repository guix.

commit bab4dc58f7278e481c7eb8c6f954d6f1751deb23
Author: Ludovic Courtès <address@hidden>
Date:   Mon Aug 20 16:31:32 2018 +0200

    import: github: Filter out tags that don't look like version numbers.
    
    * guix/import/github.scm (latest-released-version): Filter out RELEASE
    if it doesn't start with digit.
---
 guix/import/github.scm | 36 ++++++++++++++++++++++--------------
 1 file changed, 22 insertions(+), 14 deletions(-)

diff --git a/guix/import/github.scm b/guix/import/github.scm
index d11f5fa..af9f56e 100644
--- a/guix/import/github.scm
+++ b/guix/import/github.scm
@@ -172,19 +172,19 @@ 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";))
-        (let ((proper-releases
-               (filter
-                (lambda (x)
-                  ;; example pre-release:
-                  ;; https://github.com/wwood/OrfM/releases/tag/v0.5.1
-                  ;; or an all-prerelease set
-                  ;; https://github.com/powertab/powertabeditor/releases
-                  (not (hash-ref x "prerelease")))
-                json)))
-          (match proper-releases
-            (()                       ;empty release list
+        (let loop ((releases
+                    (filter
+                     (lambda (x)
+                       ;; example pre-release:
+                       ;; https://github.com/wwood/OrfM/releases/tag/v0.5.1
+                       ;; or an all-prerelease set
+                       ;; https://github.com/powertab/powertabeditor/releases
+                       (not (hash-ref x "prerelease")))
+                     json)))
+          (match releases
+            (()                                   ;empty release list
              #f)
-            ((release . rest)         ;one or more releases
+            ((release . rest)                     ;one or more releases
              (let ((tag (or (hash-ref release "tag_name") ;a "release"
                             (hash-ref release "name")))   ;a tag
                    (name-length (string-length package-name)))
@@ -196,8 +196,16 @@ https://github.com/settings/tokens";))
                    (substring tag (+ name-length 1))
                    ;; some tags start with a "v" e.g. "v0.25.0"
                    ;; where some are just the version number
-                   (if (eq? (string-ref tag 0) #\v)
-                       (substring tag 1) tag)))))))))
+                   (if (string-prefix? "v" tag)
+                       (substring tag 1)
+
+                       ;; Finally, reject tags that don't start with a digit:
+                       ;; they may not represent a release.
+                       (if (and (not (string-null? tag))
+                                (char-set-contains? char-set:digit
+                                                    (string-ref tag 0)))
+                           tag
+                           (loop rest)))))))))))
 
 (define (latest-release pkg)
   "Return an <upstream-source> for the latest release of PKG."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]