From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id AEEfO1kzIWIcWAEAgWs5BA (envelope-from ) for ; Thu, 03 Mar 2022 22:30:01 +0100 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id UFihOFkzIWK5nQAA9RJhRA (envelope-from ) for ; Thu, 03 Mar 2022 22:30:01 +0100 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 8E2D4209F6 for ; Thu, 3 Mar 2022 22:30:01 +0100 (CET) Received: from localhost ([::1]:60682 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nPt1M-0001Eh-K9 for larch@yhetil.org; Thu, 03 Mar 2022 16:30:00 -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 Content-Transfer-Encoding: 8bit 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+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1646343001; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=yWJeafeePwydXKt0CTt4A2Wg0EUsJ40BZd0C7uxqd5U=; b=dgge9wJ46hboEYkx/Ojn+mxg+ZcRxPaH1BNasGpWhtMB7hO5kWIOJ+f1NwyWV0RNtU6Myx S6/yPTrwA/1cG/s28CBfjjfOWjI90rzJJGexFQ/aGtcxgmpSf8K/a2CiWB3oKAUmOQUoms 220zI3rJtKaIBOiyDXAn49QSUGV0ZfKCyooao6fLapV79eUgjODyg1fUFHcVOJx8StPW5d Grp89SvWbt/SiXU5sMy+fcjIw9fEhSBH08N3pSoHfWB4Z7vXm7xtF1uvma2Oe0Zeamg6EB t3pHZJY/i+hz9ewACT6DmpONUnucv22mHFxsMR6CPPbtoO4hhMesxKyLjqIrfQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1646343001; a=rsa-sha256; cv=none; b=pS85E033jfjvGG886On3Jp04mNiWLHplRTJFkp/lgoY8wcojXcgXv8FP21g9hBqfwvG1Gr XaOPG7nJDg312s+yGGH70DO+zojVlNJjGOWbJ0bfgcK80ePEZ5sTPydQ7wHJJO43+F+Nqp sYRUOqfveDk0WiwnO9TdpIbNh1S8btbhMzJxm7bbZpyurBtprxXdXRq4XvC+edo1CbPIFP +U2T1+u3kZWncIzQiR+UDhk3d0MTq2r3tLQc9CD0OaybnmC4xr53ugD9Zpff+b0kEHet2z hMPLHm3AY9/tvum+nxhRRUInzsjatW4aXD/Vqp3jkWxGNy4JVo5HAy1ZByyerQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=T8qUP8WE; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -2.66 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=T8qUP8WE; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 8E2D4209F6 X-Spam-Score: -2.66 X-Migadu-Scanner: scn0.migadu.com X-TUID: 2erVLrcvi0tY * 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 -- 2.34.0