From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([209.51.188.92]:42807) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h41gw-0006cY-Id for guix-patches@gnu.org; Wed, 13 Mar 2019 07:04:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h41QZ-0008M5-TE for guix-patches@gnu.org; Wed, 13 Mar 2019 06:48:04 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:55778) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h41QZ-0008LT-7n for guix-patches@gnu.org; Wed, 13 Mar 2019 06:48:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1h41QY-0002OJ-Uo for guix-patches@gnu.org; Wed, 13 Mar 2019 06:48:02 -0400 Subject: [bug#34838] [PATCH 3/6] guix build: Factorize 'package-git-url'. Resent-Message-ID: From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Date: Wed, 13 Mar 2019 11:47:48 +0100 Message-Id: <20190313104751.20758-3-ludo@gnu.org> In-Reply-To: <20190313104751.20758-1-ludo@gnu.org> References: <20190313104751.20758-1-ludo@gnu.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: 34838@debbugs.gnu.org * guix/scripts/build.scm (package-git-url): New procedure. (evaluate-git-replacement-specs): Use it. --- guix/scripts/build.scm | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/guix/scripts/build.scm b/guix/scripts/build.scm index 5883dbfb44..7b24cc8eb1 100644 --- a/guix/scripts/build.scm +++ b/guix/scripts/build.scm @@ -275,6 +275,19 @@ current 'gnutls' package, after which version 3.5.4 is grafted onto them." (define %not-equal (char-set-complement (char-set #\=))) +(define (package-git-url package) + "Return the URL of the Git repository for package, or raise an error if +the source of PACKAGE is not fetched from a Git repository." + (let ((source (package-source package))) + (cond ((and (origin? source) + (git-reference? (origin-uri source))) + (git-reference-url (origin-uri source))) + ((git-checkout? source) + (git-checkout-url source)) + (else + (leave (G_ "the source of ~a is not a Git reference~%") + (package-full-name package)))))) + (define (evaluate-git-replacement-specs specs proc) "Parse SPECS, a list of strings like \"guile=stable-2.2\", and return a list of package pairs, where (PROC PACKAGE URL BRANCH-OR-COMMIT) returns the @@ -285,15 +298,7 @@ syntax, or if a package it refers to could not be found." ((name branch-or-commit) (let* ((old (specification->package name)) (source (package-source old)) - (url (cond ((and (origin? source) - (git-reference? (origin-uri source))) - (git-reference-url (origin-uri source))) - ((git-checkout? source) - (git-checkout-url source)) - (else - (leave (G_ "the source of ~a is not a Git \ -reference~%") - (package-full-name old)))))) + (url (package-git-url old))) (cons old (proc old url branch-or-commit)))) (x (leave (G_ "invalid replacement specification: ~s~%") spec)))) -- 2.21.0