summary refs log tree commit diff
diff options
context:
space:
mode:
authorSarah Morgensen via Guix-patches via <guix-patches@gnu.org>2021-07-15 19:01:52 -0700
committerMaxim Cournoyer <maxim.cournoyer@gmail.com>2021-07-17 23:26:52 -0400
commit5eba9c0960afdc352180f739ca3ba56f680c514b (patch)
treec4467f07af46db38bcae606e1029c4d90529eb5f
parent59d20bcfcc92e51fb451001ed52b21f6daf8013c (diff)
downloadguix-5eba9c0960afdc352180f739ca3ba56f680c514b.tar.gz
import: go: Handle multiple go-import meta tags.
* guix/import/go.scm (fetch-module-meta-data): Parse all go-import meta
tags and return the first 'module-meta' with a matching import prefix.
[go-import->module-meta]: Extract parsing into new procedure.

Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
-rw-r--r--guix/import/go.scm14
1 files changed, 9 insertions, 5 deletions
diff --git a/guix/import/go.scm b/guix/import/go.scm
index f6a68d62bb..24d12acd97 100644
--- a/guix/import/go.scm
+++ b/guix/import/go.scm
@@ -460,17 +460,21 @@ Optionally include a VERSION string to append to the name."
   "Retrieve the module meta-data from its landing page.  This is necessary
 because goproxy servers don't currently provide all the information needed to
 build a package."
+  (define (go-import->module-meta content-text)
+    (match (string-split content-text #\space)
+      ((root-path vcs repo-url)
+       (make-module-meta root-path (string->symbol vcs)
+                         (strip-.git-suffix/maybe repo-url)))))
   ;; <meta name="go-import" content="import-prefix vcs repo-root">
   (let* ((meta-data (http-fetch* (format #f "https://~a?go-get=1" module-path)))
          (select (sxpath `(// head (meta (@ (equal? (name "go-import"))))
                               // content))))
     (match (select (html->sxml meta-data #:strict? #t))
       (() #f)                           ;nothing selected
-      (((content content-text))
-       (match (string-split content-text #\space)
-         ((root-path vcs repo-url)
-          (make-module-meta root-path (string->symbol vcs)
-                            (strip-.git-suffix/maybe repo-url))))))))
+      ((('content content-text) ..1)
+       (find (lambda (meta)
+               (string-prefix? (module-meta-import-prefix meta) module-path))
+             (map go-import->module-meta content-text))))))
 
 (define (module-meta-data-repo-url meta-data goproxy)
   "Return the URL where the fetcher which will be used can download the