unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: "Ludovic Courtès" <ludo@gnu.org>
To: 34838@debbugs.gnu.org
Subject: [bug#34838] [PATCH 3/6] guix build: Factorize 'package-git-url'.
Date: Wed, 13 Mar 2019 11:47:48 +0100	[thread overview]
Message-ID: <20190313104751.20758-3-ludo@gnu.org> (raw)
In-Reply-To: <20190313104751.20758-1-ludo@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

  parent reply	other threads:[~2019-03-13 11:04 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-13  9:57 [bug#34838] [PATCH 0/6] Add '--with-git-url' and make sure it composes well Ludovic Courtès
2019-03-13 10:47 ` [bug#34838] [PATCH 1/6] guix build: Add '--with-git-url' Ludovic Courtès
2019-03-13 10:47   ` [bug#34838] [PATCH 2/6] packages: Add 'package-input-rewriting/spec' Ludovic Courtès
2019-03-13 10:47   ` Ludovic Courtès [this message]
2019-03-13 10:47   ` [bug#34838] [PATCH 4/6] guix build: Transformation options match packages by spec Ludovic Courtès
2019-03-13 10:47   ` [bug#34838] [PATCH 5/6] guix build: '--with-commit' makes recursive checkouts Ludovic Courtès
2019-03-13 10:47   ` [bug#34838] [PATCH 6/6] guix build: '--with-branch' strips slashes from the version string Ludovic Courtès
2019-03-17 21:56 ` bug#34838: [PATCH 0/6] Add '--with-git-url' and make sure it composes well Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190313104751.20758-3-ludo@gnu.org \
    --to=ludo@gnu.org \
    --cc=34838@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).