-
Notifications
You must be signed in to change notification settings - Fork 1.3k
exp show: Use tag name for all_tags.
#7008
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
Conversation
pmrowla
left a comment
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.
So the original issue isn't with tags in packed refs. The problem is with annotated (signed) tags. Normal/lightweight (unsigned) tags are already handled properly, even when they are in packed refs.
Lightweight tags are just regular git refs (where the ref points directly to a commit object's SHA).
Annotated tags are different in that the ref points to a (annotated) tag object SHA, and not a commit SHA. To go from the annotated tag name to the commit SHA, you have to actually read the tag object first to get the dereferenced commit SHA (this is generally referred to as peeling the tag object in git/dulwich/pygit/etc docs+code).
(see https://git-scm.com/docs/git-tag)
The underlying issue in DVC is that the current dulwich implementation for git.describe doesn't resolve annotated (signed) tags properly.
https://github.com/iterative/dvc/blob/cb941a836d77c845f612be29e27ae80f7a2a126c/dvc/scm/git/backend/dulwich/__init__.py#L599
I haven't investigated this issue deeply, but if I had to guess I would think that the actual bug is probably that dulwich get_ref(annotated_tag) is returning the SHA for the tag object itself, instead of returning the peeled commit SHA.
(Note that follow is unrelated to tags - it's for whether or not to follow symbolic refs. For annotated tags get_ref should always return the peeled commit SHA.)
|
Also, if you are trying to test against packed refs, you can just make some tags and then force git to pack everything in your repo with Don't do this in non-testing repos as it will pack all of your active branch refs (which will probably end up affecting performance of normal git command usage) |
Thanks! Indeed, I used that for testing on local repo but was asking more in the lines of: how to properly do this inside one of our tests? I didn't find a way to do it from Python (apart from subprocess call) |
0c1580b to
780fd23
Compare
As the problem was really about annotated tags, not |
In tests you can use CLI git directly via the (https://gitpython.readthedocs.io/en/stable/tutorial.html#using-git-directly) |
780fd23 to
5ea651a
Compare
| if isinstance(self.repo[ref], Tag): | ||
| ref = self.repo.get_peeled(name_b) |
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.
This breaks the case where name is a symbolic reference and follow = False, like when HEAD points to refs/heads/master. (see the current test failures)
Basically we need to catch KeyError when we do the self.repo[ref] check, and pass as long as follow is also False
|
@daavoo, please open this PR on the upstream. Really sorry for the inconvenience. 🙂 |
Close #6383