From patchwork Thu Mar 3 21:14:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 37600 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 3F09A27BBEA; Thu, 3 Mar 2022 21:30:04 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id E877E27BBE9 for ; Thu, 3 Mar 2022 21:30:03 +0000 (GMT) Received: from localhost ([::1]:60682 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nPt1P-0001Eh-3e for patchwork@mira.cbaines.net; Thu, 03 Mar 2022 16:30:03 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35388) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPsnv-0005g4-Qg for guix-patches@gnu.org; Thu, 03 Mar 2022 16:16:09 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:50056) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nPsnr-0007Iu-Rb for guix-patches@gnu.org; Thu, 03 Mar 2022 16:16:06 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nPsnr-0002Hk-OG for guix-patches@gnu.org; Thu, 03 Mar 2022 16:16:03 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#54241] [PATCH 4/4] import: github: Reuse HTTP connection for the /tags URL fallback. Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 03 Mar 2022 21:16:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 54241 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 54241@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= Received: via spool by 54241-submit@debbugs.gnu.org id=B54241.16463421308704 (code B ref 54241); Thu, 03 Mar 2022 21:16:03 +0000 Received: (at 54241) by debbugs.gnu.org; 3 Mar 2022 21:15:30 +0000 Received: from localhost ([127.0.0.1]:43949 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nPsnK-0002GK-Eh for submit@debbugs.gnu.org; Thu, 03 Mar 2022 16:15:30 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57782) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nPsnI-0002FV-63 for 54241@debbugs.gnu.org; Thu, 03 Mar 2022 16:15:28 -0500 Received: from [2001:470:142:3::e] (port=58928 helo=fencepost.gnu.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPsnC-00079S-6p; Thu, 03 Mar 2022 16:15:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=yWJeafeePwydXKt0CTt4A2Wg0EUsJ40BZd0C7uxqd5U=; b=T8qUP8WETPgn+gygoMB8 5P6dtkg/38+jCHrH7s7bW/gSfWXrgJaB9KRkrJuJP3u8EFTbe7RDXZ95giYUiGqnxDm0ck8UfcOt3 48FuXDDBnm25U0GMkZi7QBIINVmpimcLwtbXGeDsxsee9cO5THEi5k5DT617cFjthFddH6JRVwYtY dzXcqeBcINglirLl97iunJzi9/AT2Kq0V0eFa1Qzu4JLELsaSyb8NazbjpuqZYl01Ke7j1unbHfRY uWK153XYXk0g8tEpfB//A83gxMSc/jpomRMYz67oKHGtmAE25TvBOZbPUF1QapTEJ79smqK9Aj64d rR+iDm/QQ+0ghw==; Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201]:50082 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nPsnA-0006KA-Un; Thu, 03 Mar 2022 16:15:21 -0500 From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Thu, 3 Mar 2022 22:14:44 +0100 Message-Id: <20220303211444.19928-4-ludo@gnu.org> X-Mailer: git-send-email 2.34.0 In-Reply-To: <20220303211444.19928-1-ludo@gnu.org> References: <20220303211444.19928-1-ludo@gnu.org> MIME-Version: 1.0 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/github.scm (fetch-releases-or-tags): Call 'open-connection-for-uri' and reuse the same connection for the two 'http-fetch' calls. * .dir-locals.el (scheme-mode): Add 'call-with-port'. --- .dir-locals.el | 1 + guix/import/github.scm | 30 ++++++++++++++++++------------ 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/.dir-locals.el b/.dir-locals.el index 0edf2a8d23..bee745cc27 100644 --- a/.dir-locals.el +++ b/.dir-locals.el @@ -52,6 +52,7 @@ (eval . (put 'test-equal 'scheme-indent-function 1)) (eval . (put 'test-eq 'scheme-indent-function 1)) (eval . (put 'call-with-input-string 'scheme-indent-function 1)) + (eval . (put 'call-with-port 'scheme-indent-function 1)) (eval . (put 'guard 'scheme-indent-function 1)) (eval . (put 'lambda* 'scheme-indent-function 1)) (eval . (put 'substitute* 'scheme-indent-function 1)) diff --git a/guix/import/github.scm b/guix/import/github.scm index 5062bad80d..84f70eed0f 100644 --- a/guix/import/github.scm +++ b/guix/import/github.scm @@ -33,6 +33,7 @@ (define-module (guix import github) #:use-module ((guix ui) #:select (display-hint)) #:use-module ((guix download) #:prefix download:) #:use-module ((guix git-download) #:prefix download:) + #:autoload (guix build download) (open-connection-for-uri) #:use-module (guix import utils) #:use-module (json) #:use-module (guix packages) @@ -226,18 +227,23 @@ (define headers (_ (raise c))))) - (let* ((port (http-fetch release-url #:headers headers)) - (result (json->scm port))) - (close-port port) - (match result - (#() - ;; We got the empty list, presumably because the user didn't use GitHub's - ;; "release" mechanism, but hopefully they did use Git tags. - (let* ((port (http-fetch tag-url #:headers headers)) - (json (json->scm port))) - (close-port port) - json)) - (x x)))))) + (let ((release-uri (string->uri release-url))) + (call-with-port (open-connection-for-uri release-uri) + (lambda (connection) + (let* ((result (json->scm + (http-fetch release-uri + #:port connection + #:keep-alive? #t + #:headers headers)))) + (match result + (#() + ;; We got the empty list, presumably because the user didn't use GitHub's + ;; "release" mechanism, but hopefully they did use Git tags. + (json->scm (http-fetch tag-url + #:port connection + #:keep-alive? #t + #:headers headers))) + (x x))))))))) (define (latest-released-version url package-name) "Return the newest released version and its tag given a string URL like