unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#50289] [PATCH] import: go: Fix import when import path redirects.
@ 2021-08-31  2:05 Sarah Morgensen
  2021-09-07 13:55 ` bug#50289: " Ludovic Courtès
  0 siblings, 1 reply; 2+ messages in thread
From: Sarah Morgensen @ 2021-08-31  2:05 UTC (permalink / raw)
  To: 50289; +Cc: Attila Lendvai

* guix/import/go.scm (fetch-module-meta-data): If no meta entries
have a matching import prefix, return the first entry instead of #f.
---
X-Debbugs-CC: Attila Lendvai <attila@lendvai.name>

Hello Guix,

As reported by Attila on IRC, the Go importer currently chokes when the
import path URL redirects, for example with "github.com/prometheus/tsdb".

This is due to my modification to 'fetch-module-meta-data' to handle multiple
package's meta tags on one page [0].  It selects the meta based on whether its
import prefix matches the URL we requested.  This breaks when the URL
redirects but the import path is not changed (I did not realize that this
was valid... go figure).  This patch fixes that by falling back to the first
meta if none match.

[0] https://issues.guix.gnu.org/49591

--
Sarah

 guix/import/go.scm | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/guix/import/go.scm b/guix/import/go.scm
index 617a0d0e23..57a135b9a9 100644
--- a/guix/import/go.scm
+++ b/guix/import/go.scm
@@ -483,9 +483,12 @@ (define (fetch-module-meta-data module-path)
     (match (select (html->sxml meta-data #:strict? #t))
       (() #f)                           ;nothing selected
       ((('content content-text) ..1)
-       (find (lambda (meta)
-               (string-prefix? (module-meta-import-prefix meta) module-path))
-             (map go-import->module-meta content-text))))))
+       (or
+        (find (lambda (meta)
+                (string-prefix? (module-meta-import-prefix meta) module-path))
+              (map go-import->module-meta content-text))
+        ;; Fallback to the first meta if no import prefixes match.
+        (go-import->module-meta (first content-text)))))))
 
 (define (module-meta-data-repo-url meta-data goproxy)
   "Return the URL where the fetcher which will be used can download the

base-commit: 994d8ce394e88b55985241b7b14f6a8459bcf9e8
-- 
2.31.1





^ permalink raw reply related	[flat|nested] 2+ messages in thread

* bug#50289: [PATCH] import: go: Fix import when import path redirects.
  2021-08-31  2:05 [bug#50289] [PATCH] import: go: Fix import when import path redirects Sarah Morgensen
@ 2021-09-07 13:55 ` Ludovic Courtès
  0 siblings, 0 replies; 2+ messages in thread
From: Ludovic Courtès @ 2021-09-07 13:55 UTC (permalink / raw)
  To: Sarah Morgensen; +Cc: Attila Lendvai, 50289-done

Hi,

Sarah Morgensen <iskarian@mgsn.dev> skribis:

> * guix/import/go.scm (fetch-module-meta-data): If no meta entries
> have a matching import prefix, return the first entry instead of #f.
> ---
> X-Debbugs-CC: Attila Lendvai <attila@lendvai.name>
>
> Hello Guix,
>
> As reported by Attila on IRC, the Go importer currently chokes when the
> import path URL redirects, for example with "github.com/prometheus/tsdb".
>
> This is due to my modification to 'fetch-module-meta-data' to handle multiple
> package's meta tags on one page [0].  It selects the meta based on whether its
> import prefix matches the URL we requested.  This breaks when the URL
> redirects but the import path is not changed (I did not realize that this
> was valid... go figure).  This patch fixes that by falling back to the first
> meta if none match.
>
> [0] https://issues.guix.gnu.org/49591

Applied, thank you!

Ludo’.




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-09-07 14:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-31  2:05 [bug#50289] [PATCH] import: go: Fix import when import path redirects Sarah Morgensen
2021-09-07 13:55 ` bug#50289: " Ludovic Courtès

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).