mirror of
https://git.savannah.gnu.org/git/guix.git
synced 2025-01-23 02:36:40 +01:00
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>
This commit is contained in:
parent
59d20bcfcc
commit
5eba9c0960
1 changed files with 9 additions and 5 deletions
|
@ -460,17 +460,21 @@ (define (fetch-module-meta-data module-path)
|
||||||
"Retrieve the module meta-data from its landing page. This is necessary
|
"Retrieve the module meta-data from its landing page. This is necessary
|
||||||
because goproxy servers don't currently provide all the information needed to
|
because goproxy servers don't currently provide all the information needed to
|
||||||
build a package."
|
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">
|
;; <meta name="go-import" content="import-prefix vcs repo-root">
|
||||||
(let* ((meta-data (http-fetch* (format #f "https://~a?go-get=1" module-path)))
|
(let* ((meta-data (http-fetch* (format #f "https://~a?go-get=1" module-path)))
|
||||||
(select (sxpath `(// head (meta (@ (equal? (name "go-import"))))
|
(select (sxpath `(// head (meta (@ (equal? (name "go-import"))))
|
||||||
// content))))
|
// content))))
|
||||||
(match (select (html->sxml meta-data #:strict? #t))
|
(match (select (html->sxml meta-data #:strict? #t))
|
||||||
(() #f) ;nothing selected
|
(() #f) ;nothing selected
|
||||||
(((content content-text))
|
((('content content-text) ..1)
|
||||||
(match (string-split content-text #\space)
|
(find (lambda (meta)
|
||||||
((root-path vcs repo-url)
|
(string-prefix? (module-meta-import-prefix meta) module-path))
|
||||||
(make-module-meta root-path (string->symbol vcs)
|
(map go-import->module-meta content-text))))))
|
||||||
(strip-.git-suffix/maybe repo-url))))))))
|
|
||||||
|
|
||||||
(define (module-meta-data-repo-url meta-data goproxy)
|
(define (module-meta-data-repo-url meta-data goproxy)
|
||||||
"Return the URL where the fetcher which will be used can download the
|
"Return the URL where the fetcher which will be used can download the
|
||||||
|
|
Loading…
Reference in a new issue