diff mbox series

[bug#58433,2/2] channels: Interpret the 'commit' field of channel as a tag or commit.

Message ID 20221011095229.31244-2-ludo@gnu.org
State Accepted
Headers show
Series Accept tags in the 'commit' field of <channel> | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git-branch success View Git branch
cbaines/applying patch fail View Laminar job
cbaines/issue success View issue

Commit Message

Ludovic Courtès Oct. 11, 2022, 9:52 a.m. UTC
Previously the 'commit' field would always be interpreted as a commit
ID.  This change adds flexibility, allowing for things like:

  guix time-machine --commit=v1.2.0 -- describe

* guix/channels.scm (channel-reference): Use 'tag-or-commit' rather than 'commit'.
* guix/inferior.scm (channel-full-commit): Likewise.
* doc/guix.texi (Invoking guix pull): Document it.
(Invoking guix time-machine): Likewise.
---
 doc/guix.texi     | 23 +++++++++++++++++++++--
 guix/channels.scm |  2 +-
 guix/inferior.scm |  2 +-
 3 files changed, 23 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/doc/guix.texi b/doc/guix.texi
index 14592142dd..4c24600f04 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -4631,7 +4631,7 @@  but it supports the following options:
 @itemx --branch=@var{branch}
 Download code for the @code{guix} channel from the specified @var{url}, at the
 given @var{commit} (a valid Git commit ID represented as a hexadecimal
-string), or @var{branch}.
+string or the name of a tag), or @var{branch}.
 
 @cindex @file{channels.scm}, configuration file
 @cindex configuration file for channels
@@ -4783,6 +4783,25 @@  of Guix to be used is defined by a commit or by a channel
 description file created by @command{guix describe}
 (@pxref{Invoking guix describe}).
 
+Let's assume that you want to travel to those days of November 2020 when
+version 1.2.0 of Guix was released and, once you're there, run the
+@command{guile} of that time:
+
+@example
+guix time-machine --commit=v1.2.0 -- \
+  environment -C --ad-hoc guile -- guile
+@end example
+
+The command above fetches Guix@tie{}1.2.0 and runs its @command{guix
+environment} command to spawn an environment in a container running
+@command{guile} (@command{guix environment} has since been subsumed by
+@command{guix shell}; @pxref{Invoking guix shell}).  It's like driving a
+DeLorean@footnote{If you don't know what a DeLorean is, consider
+traveling back to the 1980's.}!  The first @command{guix time-machine}
+invocation can be expensive: it may have to download or even build a
+large number of packages; the result is cached though and subsequent
+commands targeting the same commit are almost instantaneous.
+
 The general syntax is:
 
 @example
@@ -4799,7 +4818,7 @@  this revision are the same as for @command{guix pull} (@pxref{Invoking guix pull
 @itemx --branch=@var{branch}
 Use the @code{guix} channel from the specified @var{url}, at the
 given @var{commit} (a valid Git commit ID represented as a hexadecimal
-string), or @var{branch}.
+string or the name of a tag), or @var{branch}.
 
 @item --channels=@var{file}
 @itemx -C @var{file}
diff --git a/guix/channels.scm b/guix/channels.scm
index f1c23c17fb..d84228c47e 100644
--- a/guix/channels.scm
+++ b/guix/channels.scm
@@ -248,7 +248,7 @@  (define (channel-reference channel)
 'latest-repository-commit'."
   (match (channel-commit channel)
     (#f      `(branch . ,(channel-branch channel)))
-    (commit  `(commit . ,(channel-commit channel)))))
+    (commit  `(tag-or-commit . ,(channel-commit channel)))))
 
 (define sexp->channel-introduction
   (match-lambda
diff --git a/guix/inferior.scm b/guix/inferior.scm
index cbb3c0a36e..2fe34ca0dc 100644
--- a/guix/inferior.scm
+++ b/guix/inferior.scm
@@ -835,7 +835,7 @@  (define (channel-full-commit channel)
         (branch (channel-branch channel)))
     (if (and commit (commit-id? commit))
         commit
-        (let* ((ref (if commit `(commit . ,commit) `(branch . ,branch)))
+        (let* ((ref (if commit `(tag-or-commit . ,commit) `(branch . ,branch)))
                (cache commit relation
                      (update-cached-checkout (channel-url channel)
                                              #:ref ref