From patchwork Tue Aug 31 02:05:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sarah Morgensen X-Patchwork-Id: 32433 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 9BADB27BBE3; Tue, 31 Aug 2021 03:06:10 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,T_DKIM_INVALID, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 557D327BBE1 for ; Tue, 31 Aug 2021 03:06:10 +0100 (BST) Received: from localhost ([::1]:54054 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mKtA9-0008KD-AU for patchwork@mira.cbaines.net; Mon, 30 Aug 2021 22:06:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41354) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mKtA2-0008JN-IJ for guix-patches@gnu.org; Mon, 30 Aug 2021 22:06:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:49170) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mKtA2-0002k1-8W for guix-patches@gnu.org; Mon, 30 Aug 2021 22:06:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mKtA1-0003Ay-PV; Mon, 30 Aug 2021 22:06:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#50289] [PATCH] import: go: Fix import when import path redirects. Resent-From: Sarah Morgensen Original-Sender: "Debbugs-submit" Resent-CC: attila@lendvai.name, guix-patches@gnu.org Resent-Date: Tue, 31 Aug 2021 02:06:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 50289 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 50289@debbugs.gnu.org Cc: Attila Lendvai X-Debbugs-Original-To: guix-patches@gnu.org X-Debbugs-Original-Xcc: Attila Lendvai Received: via spool by submit@debbugs.gnu.org id=B.163037554112152 (code B ref -1); Tue, 31 Aug 2021 02:06:01 +0000 Received: (at submit) by debbugs.gnu.org; 31 Aug 2021 02:05:41 +0000 Received: from localhost ([127.0.0.1]:60710 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mKt9h-00039w-Hn for submit@debbugs.gnu.org; Mon, 30 Aug 2021 22:05:41 -0400 Received: from lists.gnu.org ([209.51.188.17]:57434) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mKt9c-00039l-CA for submit@debbugs.gnu.org; Mon, 30 Aug 2021 22:05:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41274) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mKt9Y-0008CF-Ut for guix-patches@gnu.org; Mon, 30 Aug 2021 22:05:36 -0400 Received: from out2.migadu.com ([2001:41d0:2:aacc::]:37571) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mKt9V-0002LJ-2e for guix-patches@gnu.org; Mon, 30 Aug 2021 22:05:32 -0400 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mgsn.dev; s=key1; t=1630375522; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=kQE/QMOilsNZXvQzOCE7aHE6RQoYdUpKJ+BrVIQaV5Y=; b=Iqs1blDc2j3VSl+X9NU8cr6Hks+GRENKFjsqq9gcfHmKAxVJCfFvmXC2D6lv1ENAjZWLEi C/07WqtBJ1UuZW6yKUaxejtMTp+r2H5gffy4BQ/wAkfFrWMjUD9n5OzsUqYxeUp3vDQ1b1 VPJHqpfHrPOv/2bnPCEsaDZ2uaudKI0= From: Sarah Morgensen Date: Mon, 30 Aug 2021 19:05:19 -0700 Message-Id: MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: iskarian@mgsn.dev Received-SPF: pass client-ip=2001:41d0:2:aacc::; envelope-from=iskarian@mgsn.dev; helo=out2.migadu.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * 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 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(-) base-commit: 994d8ce394e88b55985241b7b14f6a8459bcf9e8 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