-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for annotated git tags #2570
Conversation
How do I reproduce this? |
Here's a repro-case (please forgive the size):
I then start up buildkit which listen on
On thing that's interesting to note, is that when I used
it works. So what's the difference?
So when I run I see:
However in the case of the buildx git example:
and
so it appears that the difference is related to the handling of signed vs unsigned commits. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still quite confused about this.
It looks like it's annotated tag that causes issue, but I still don't really understand the case or what that error means.
I'd like to avoid refs with random ID where possible. I think this one also has the issue that if user would look up the current tag from checkout then it would not show the correct information.
I tried to run these commands manually. One of the things I found was that.
» git fetch -u --depth=1 origin v2.30.0:v2.30.0
remote: Enumerating objects: 3961, done.
remote: Counting objects: 100% (3961/3961), done.
remote: Compressing objects: 100% (3480/3480), done.
remote: Total 3961 (delta 314), reused 3961 (delta 314), pack-reused 0
Receiving objects: 100% (3961/3961), 9.60 MiB | 65.99 MiB/s, done.
Resolving deltas: 100% (314/314), done.
error: cannot update ref 'refs/heads/v2.30.0': trying to write non-commit object 2d9685d47a7e516281aa093bf0cddc8aafa72448 to branch 'refs/heads/v2.30.0'
From ../a
! [new tag] v2.30.0 -> v2.30.0 (unable to update local ref)
* [new tag] v2.30.0 -> v2.30.0
is error (although afaics it does actually create the tag correctly, just error code is wrong).
» git fetch -u --depth=1 origin v2.30.0:refs/tags/v2.30.0
remote: Enumerating objects: 3961, done.
remote: Counting objects: 100% (3961/3961), done.
remote: Compressing objects: 100% (3480/3480), done.
remote: Total 3961 (delta 314), reused 3961 (delta 314), pack-reused 0
Receiving objects: 100% (3961/3961), 9.60 MiB | 63.85 MiB/s, done.
Resolving deltas: 100% (314/314), done.
From ../a
* [new tag] v2.30.0 -> v2.30.0
No error.
I can't fully understand what defines this behavior though.
That's an interesting observation! If it's helpful, I can re-work the |
Only if this is needed to trigger this error case. I doubt the actual signature makes a difference but could be the tag annotation. Also validate that the requested tag is visible from the final snapshot. It doesn't look like it would be the case with the current implementation. |
I might be able to shed some light on some of this behavior. I'm not an expert in this domain, but I've been following this with interest.
I actually get slightly different results (probably due to how buildkit clones/pulls vs. my end-user clone), but with a "full" clone:
I already had the tag (thus no new tag was created) but I had the same error. But, if I clone without tags (
So I got the exact same error and no tag was created. The lack of existing tag was not a trigger to create one despite the error (for me at least). Why your invocation created one but mine didn't is curious, but probably not relevant.
This does appear to have a logical explanation from what I'm reading. If you look closely, the unqualified
That explains the behavior between those two invocations, and despite both
I'm just now seeing that this distinction is also made on the very first line of a standard
In summary:
Again, hopefully this is a help and not a hindrance... I just have a vested interest in this being implemented. Thanks for the work and effort! |
@rrjjvv Thanks for the debug.
https://gist.github.com/tonistiigi/d5391881660eb8554235df5252515108 has the commands I captured that buildkit currently runs. So I guess the option left is to detect this case and use |
That should solve the technical issue. I guess the real question is whether you see this as "we support using tags", or "you can use tags as a shortcut". That could drive whether you truly store them as tags or whether you translate non-SHAs to SHAs on the front end. But I'm guessing that you already "support branches" (and store them as such), so using
No, I don't think you're missing something, but it might not be a simple binary right-or-wrong. But I think there are two separate (but related) issues and breaking them apart might add some clarity. My original desire, in Alex's project, was to check out a tag. Even more specifically, I wanted to build git version 2.33.0. Between my trust of that project and my requirements, cloning I then took the next logical step and figured "fine, what commit does that tag point to?". Having the code already cloned, I did a simple That's when I started "trying stuff" in preparation for a bug report. I literally went to https://git.kernel.org/pub/scm/git/git.git/tag/?h=v2.30.0 and plugged in that SHA ( I think Alex's PR was truly focused on the first scenario. As a git end-user (using I'm not clear whether "what happens if I directly use a commit SHA" or "what happens if I directly use an annotated tag SHA" are questions that need answering. I'm guessing both already have well-defined behaviors (though I would think that being truthful would be the logical and expected behavior) TL;DR; after my rambling, I'm too new to your world to give (educated) feedback or opinions. But there is precedent in fibbing about the SHA (showing the dereferenced commit rather than the annotated tag) in high-level git tooling. And by specifying a tag, you're implicitly giving up exactness for convenience. I think both (dereferencing and not) are equally defendable. |
2e806b8
to
9c1cd60
Compare
This fixes errors such as: error: cannot update ref 'refs/heads/v2.30.0': trying to write non-commit object 2d9685d47a7e516281aa093bf0cddc8aafa72448 to branch 'refs/heads/v2.30.0' which occur when cloning a tag rather than branch. Signed-off-by: Alex Couture-Beil <alex@earthly.dev>
9c1cd60
to
9e1a9d2
Compare
Thanks for the great discussion @rrjjvv and @tonistiigi, I added in an explicit check for lightweight tags vs annotated tags: When we run lightweight
In this case we'll keep the existing pullRef such as annotated
In this case, we'll set pullRef to something similar to: @tonistiigi I expanded the tests to cover both lightweight and annotated tags. I was torn between creating two separate |
This fixes errors such as:
which occur when cloning a tag rather than branch.
Signed-off-by: Alex Couture-Beil alex@earthly.dev