unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: "Ludovic Courtès" <ludo@gnu.org>
To: 33522@debbugs.gnu.org
Cc: "Ludovic Courtès" <ludovic.courtes@inria.fr>
Subject: [bug#33522] [PATCH 2/3] git: Add <git-checkout> record type.
Date: Tue, 27 Nov 2018 16:34:01 +0100	[thread overview]
Message-ID: <20181127153402.21357-2-ludo@gnu.org> (raw)
In-Reply-To: <20181127153402.21357-1-ludo@gnu.org>

From: Ludovic Courtès <ludovic.courtes@inria.fr>

* guix/git.scm (<git-checkout>): New record type.
(latest-repository-commit*): New procedure.
(git-checkout-compiler): New gexp compiler.
---
 guix/git.scm | 34 +++++++++++++++++++++++++++++++++-
 1 file changed, 33 insertions(+), 1 deletion(-)

diff --git a/guix/git.scm b/guix/git.scm
index 78645024c9..56cebb06ed 100644
--- a/guix/git.scm
+++ b/guix/git.scm
@@ -25,6 +25,8 @@
   #:use-module ((guix build utils) #:select (mkdir-p))
   #:use-module (guix store)
   #:use-module (guix utils)
+  #:use-module (guix records)
+  #:use-module (guix gexp)
   #:use-module (rnrs bytevectors)
   #:use-module (ice-9 match)
   #:use-module (srfi srfi-1)
@@ -33,7 +35,12 @@
   #:use-module (srfi srfi-35)
   #:export (%repository-cache-directory
             update-cached-checkout
-            latest-repository-commit))
+            latest-repository-commit
+
+            git-checkout
+            git-checkout?
+            git-checkout-url
+            git-checkout-branch))
 
 (define %repository-cache-directory
   (make-parameter (string-append (cache-directory #:ensure? #f)
@@ -185,3 +192,28 @@ Log progress and checkout info to LOG-PORT."
     (values (add-to-store store name #t "sha256" checkout
                           #:select? (negate dot-git?))
             commit)))
+
+\f
+;;;
+;;; Checkouts.
+;;;
+
+;; Representation of the "latest" checkout of a branch.
+(define-record-type* <git-checkout>
+  git-checkout make-git-checkout
+  git-checkout?
+  (url     git-checkout-url)
+  (branch  git-checkout-branch (default "master")))
+
+(define latest-repository-commit*
+  (store-lift latest-repository-commit))
+
+(define-gexp-compiler (git-checkout-compiler (checkout <git-checkout>)
+                                             system target)
+  ;; "Compile" CHECKOUT by updating the local checkout and adding it to the
+  ;; store.
+  (match checkout
+    (($ <git-checkout> url branch)
+     (latest-repository-commit* url
+                                #:ref `(branch . ,branch)
+                                #:log-port (current-error-port)))))
-- 
2.19.2

  reply	other threads:[~2018-11-27 15:35 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-27 15:31 [bug#33522] [PATCH 0/3] Add the '--with-branch' package transformation option Ludovic Courtès
2018-11-27 15:34 ` [bug#33522] [PATCH 1/3] git: 'latest-repository-commit' logs its progress Ludovic Courtès
2018-11-27 15:34   ` Ludovic Courtès [this message]
2018-11-27 15:34   ` [bug#33522] [PATCH 3/3] guix build: Add '--with-branch' transformation option Ludovic Courtès
2018-11-30 16:04 ` bug#33522: [PATCH 0/3] Add the '--with-branch' package " 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=20181127153402.21357-2-ludo@gnu.org \
    --to=ludo@gnu.org \
    --cc=33522@debbugs.gnu.org \
    --cc=ludovic.courtes@inria.fr \
    /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).