GNU bug report logs -
#58433
[PATCH 0/2] Accept tags in the 'commit' field of <channel>
Previous Next
Reported by: Ludovic Courtès <ludo <at> gnu.org>
Date: Tue, 11 Oct 2022 09:52:02 UTC
Severity: normal
Tags: patch
Done: Ludovic Courtès <ludo <at> gnu.org>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 58433 in the body.
You can then email your comments to 58433 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
guix-patches <at> gnu.org
:
bug#58433
; Package
guix-patches
.
(Tue, 11 Oct 2022 09:52:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Ludovic Courtès <ludo <at> gnu.org>
:
New bug report received and forwarded. Copy sent to
guix-patches <at> gnu.org
.
(Tue, 11 Oct 2022 09:52:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
Hi!
This change lets us pass tags to ‘guix time-machine’ and ‘guix pull’,
as in:
guix time-machine --commit=v1.2.0 -- describe
At last!
Thoughts?
Ludo’.
Ludovic Courtès (2):
git: 'update-cached-checkout' returns the commit ID when given a tag.
channels: Interpret the 'commit' field of channel as a tag or commit.
doc/guix.texi | 23 +++++++++++++++++++++--
guix/channels.scm | 2 +-
guix/git.scm | 15 +++++++++------
guix/inferior.scm | 2 +-
tests/git.scm | 32 +++++++++++++++++++++++++++++++-
5 files changed, 63 insertions(+), 11 deletions(-)
base-commit: 5d5bc072059f514394afdaccfcc72cdb282d7ce2
--
2.38.0
Information forwarded
to
guix-patches <at> gnu.org
:
bug#58433
; Package
guix-patches
.
(Tue, 11 Oct 2022 09:53:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 58433 <at> debbugs.gnu.org (full text, mbox):
Previously, starting with commit
efa578ecaece67366b4b0e2266de7c2faaa4ae54, 'update-cached-checkout' would
return the OID of the annotated tag the tag points to. With this change
it returns the OID of the commit object in all cases.
* guix/git.scm (resolve-reference): In the 'tag' case, call
'tag-target-id' and 'tag-lookup' when OID designates an annotated tag.
* tests/git.scm ("update-cached-checkout, tag"): New test.
---
guix/git.scm | 15 +++++++++------
tests/git.scm | 32 +++++++++++++++++++++++++++++++-
2 files changed, 40 insertions(+), 7 deletions(-)
diff --git a/guix/git.scm b/guix/git.scm
index d7fd320f50..0220fe1068 100644
--- a/guix/git.scm
+++ b/guix/git.scm
@@ -271,12 +271,15 @@ (define (resolve-reference repository ref)
;; There's no such tag, so it must be a commit ID.
(resolve `(commit . ,str)))))))
(('tag . tag)
- (let ((oid (reference-name->oid repository
- (string-append "refs/tags/" tag))))
- ;; OID may point to a "tag" object, but it can also point directly
- ;; to a "commit" object, as surprising as it may seem. Return that
- ;; object, whatever that is.
- (object-lookup repository oid))))))
+ (let* ((oid (reference-name->oid repository
+ (string-append "refs/tags/" tag)))
+ (obj (object-lookup repository oid)))
+ ;; OID may designate an "annotated tag" object or a "commit" object.
+ ;; Return the commit object in both cases.
+ (if (= OBJ-TAG (object-type obj))
+ (object-lookup repository
+ (tag-target-id (tag-lookup repository oid)))
+ obj))))))
(define (switch-to-ref repository ref)
"Switch to REPOSITORY's branch, commit or tag specified by REF. Return the
diff --git a/tests/git.scm b/tests/git.scm
index ca59d2a33e..9c944d65b1 100644
--- a/tests/git.scm
+++ b/tests/git.scm
@@ -22,8 +22,12 @@ (define-module (test-git)
#:use-module (guix git)
#:use-module (guix tests git)
#:use-module (guix build utils)
+ #:use-module ((guix utils) #:select (call-with-temporary-directory))
#:use-module (srfi srfi-1)
- #:use-module (srfi srfi-64))
+ #:use-module (srfi srfi-64)
+ #:use-module (srfi srfi-71)
+ #:use-module (ice-9 popen)
+ #:use-module (ice-9 textual-ports))
;; Test the (guix git) tools.
@@ -239,4 +243,30 @@ (define-module (test-git)
(tag "v1.1" "Release 1.1"))
(remote-refs directory #:tags? #t)))
+(unless (which (git-command)) (test-skip 1))
+(test-assert "update-cached-checkout, tag"
+ (call-with-temporary-directory
+ (lambda (cache)
+ (with-temporary-git-repository directory
+ '((add "a.txt" "A")
+ (commit "First commit")
+ (tag "v1.0" "release-1.0")
+ (branch "develop")
+ (checkout "develop")
+ (add "b.txt" "B")
+ (commit "Second commit")
+ (tag "v1.1" "release-1.1"))
+ (let ((directory commit relation
+ (update-cached-checkout directory
+ #:ref '(tag . "v1.1")
+ #:cache-directory cache))
+ (head (let* ((pipe (open-pipe* OPEN_READ (git-command)
+ "-C" directory
+ "rev-parse" "HEAD"))
+ (str (get-string-all pipe)))
+ (close-pipe pipe)
+ (string-trim-right str))))
+ ;; COMMIT should be the ID of the commit object, not that of the tag.
+ (string=? commit head))))))
+
(test-end "git")
--
2.38.0
Information forwarded
to
guix-patches <at> gnu.org
:
bug#58433
; Package
guix-patches
.
(Tue, 11 Oct 2022 09:53:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 58433 <at> debbugs.gnu.org (full text, mbox):
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 --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 <at> 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 <at> 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
--
2.38.0
Information forwarded
to
guix-patches <at> gnu.org
:
bug#58433
; Package
guix-patches
.
(Thu, 13 Oct 2022 13:04:02 GMT)
Full text and
rfc822 format available.
Message #14 received at 58433 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Ludovic Courtès <ludo <at> gnu.org> writes:
> This change lets us pass tags to ‘guix time-machine’ and ‘guix pull’,
> as in:
>
> guix time-machine --commit=v1.2.0 -- describe
>
> At last!
>
> Thoughts?
This sounds good to me :)
Thanks,
Chris
[signature.asc (application/pgp-signature, inline)]
Reply sent
to
Ludovic Courtès <ludo <at> gnu.org>
:
You have taken responsibility.
(Mon, 17 Oct 2022 08:48:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
Ludovic Courtès <ludo <at> gnu.org>
:
bug acknowledged by developer.
(Mon, 17 Oct 2022 08:48:02 GMT)
Full text and
rfc822 format available.
Message #19 received at 58433-done <at> debbugs.gnu.org (full text, mbox):
Hi,
Christopher Baines <mail <at> cbaines.net> skribis:
> Ludovic Courtès <ludo <at> gnu.org> writes:
>
>> This change lets us pass tags to ‘guix time-machine’ and ‘guix pull’,
>> as in:
>>
>> guix time-machine --commit=v1.2.0 -- describe
>>
>> At last!
>>
>> Thoughts?
>
> This sounds good to me :)
Pushed, thanks for taking a look!
f36522416e * channels: Interpret the 'commit' field of channel as a tag or commit.
46f7011591 * git: 'update-cached-checkout' returns the commit ID when given a tag.
Ludo’.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Mon, 14 Nov 2022 12:24:05 GMT)
Full text and
rfc822 format available.
This bug report was last modified 2 years and 302 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.