summaryrefslogtreecommitdiff
path: root/guix/scripts/time-machine.scm
diff options
context:
space:
mode:
authorMaxim Cournoyer <maxim.cournoyer@gmail.com>2023-09-05 17:04:12 -0400
committerMaxim Cournoyer <maxim.cournoyer@gmail.com>2023-09-05 19:52:20 -0400
commitc3d48d024b95f57850ec429d7f326d817dda5090 (patch)
tree6820b0770f03d69bf2ed406fa6823ae8a4fbe3ec /guix/scripts/time-machine.scm
parent756e336fa008c2469b4a7317ad5c641ed48f25d6 (diff)
time-machine: Also validate the reference from a channels file.
* guix/scripts/time-machine.scm (guix-time-machine) <validate-guix-channel>: Update doc. Fall-back to use the Guix channel reference when REF is #f. Reported-by: Simon Tournier <zimon.toutoune@gmail.com> Co-authored-by: Simon Tournier <zimon.toutoune@gmail.com>
Diffstat (limited to 'guix/scripts/time-machine.scm')
-rw-r--r--guix/scripts/time-machine.scm15
1 files changed, 11 insertions, 4 deletions
diff --git a/guix/scripts/time-machine.scm b/guix/scripts/time-machine.scm
index 87000d82ec..3ecf735acb 100644
--- a/guix/scripts/time-machine.scm
+++ b/guix/scripts/time-machine.scm
@@ -164,13 +164,20 @@ Execute COMMAND ARGS... in an older version of Guix.\n"))
(define (validate-guix-channel channels)
"Finds the Guix channel among CHANNELS, and validates that REF as
captured from the closure, a git reference specification such as a commit hash
-or tag associated to CHANNEL, is valid and new enough to satisfy the 'guix
-time-machine' requirements. A `formatted-message' condition is raised
-otherwise."
+or tag associated to the channel, is valid and new enough to satisfy the 'guix
+time-machine' requirements. If the captured REF variable is #f, the reference
+validate is the one of the Guix channel found in CHANNELS. A
+`formatted-message' condition is raised otherwise."
(let* ((guix-channel (find guix-channel? channels))
+ (guix-channel-commit (channel-commit guix-channel))
+ (guix-channel-branch (channel-branch guix-channel))
+ (guix-channel-ref (if guix-channel-commit
+ `(tag-or-commit . ,guix-channel-commit)
+ `(branch . ,guix-channel-branch)))
+ (reference (or ref guix-channel-ref))
(checkout commit relation (update-cached-checkout
(channel-url guix-channel)
- #:ref (or ref '())
+ #:ref reference
#:starting-commit
%oldest-possible-commit)))
(unless (memq relation '(ancestor self))