-
-
Notifications
You must be signed in to change notification settings - Fork 8
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
Unreachable git commits are used for Go module version determination #505
Comments
Oh good, a git issue, those are usually easy to track down 😅. If you’re able to create a reproduction and paste the git commands that set up a problematic repo, that’d be super helpful! If not, I’ll try to tinker around and find it. I don’t think I have any tests with tags on multiple branches yet, so maybe it’s as simple as doing that 🤔 |
Hm, I thought I'd be able to, but I set up a minimal repo with the setup I described above (using |
(I have added some other oddities to that demo repo try to better match the repo where I saw the problem, including adding a |
@BatmanAoD is it possible this is related to #502 and that the perceived, unreachable tag was not the tag being read—but instead there was a tag in the wrong format which knope was using? |
Hm...I will play with the dummy repo a bit more to see if maybe that can cause it, but I'm pretty sure it's definitely the case that I was seeing a version based on an unreachable tag. |
No, this behavior definitely occurs even when there is only one possible tag where it could be getting that specific version. |
Okay, I've updated the demo repo and it now demonstrates the issue; on the Looking at the code, it seems that the determination of the current version doesn't actually use the It also appears that when collecting commit messages, only the latest version is used to stop traversal. Unfortunately, I don't think this will ever work reliably, because if merges are not squashed, there will often be a way to "bypass" a specific release while traversing the parent commits. I believe this is why we've seen Knope decide for some repositories that it is always time for a "major" release. |
Here's a visual demonstration of how there can be a commit graph that permits traversal to "bypass" major tags. The I think the way to reliably determine the correct set of commits must be:
|
Well... I think I am wrong about the current implementation handling that specific case of "bypassing" the last tag, because I built a repo to check and Knope correctly recognizes the next release as v2.0.1. But that makes it even stranger that in some cases Knope does seem to go much further back in the commit history than it should. |
Yeah… I tried to build a repro test to validate a fix and it worked properly (so I couldn’t validate). But then I manually made a repo and was able to get it to do the wrong thing. So… something is very confusing. I think I can use a rev parse function to do things properly. |
For what it's worth, I started a discussion in the git-oxide repo about constructing a "diff" of commits like this: Byron/gitoxide#1017 |
...however, this specific issue was originally just about ignoring unreachable tags when determining the current version. That part, at least, seems fairly straightforwardly solvable. |
Okay, I figured out why it's inconsistent! It's doing a breadth-first search right now, but the inner-sorting of that breadth-first seems to be topological order.. or something equivalent. So if I merge main into breaking before committing the second fix, it just so happens that the order Knope processes the commits means it won't see the the previous tag until after it goes too far down the branch. None that that really matters (beyond giving me a failing test case to test the solution against), but it's very satisfying to know what was happening 😅. I've created a really bad solution in #574 just to get the bug fixed—it's going to tank performance on really large projects, but I don't have time to build a graph-painting algorithm right now and I don't want this to keep blocking you 😁. It'll be a fun future enhancement to make commit traversal much more efficient (especially for linear histories). |
I think slow but reliable is good for now! What about the issue of making sure the last-release is actually reachable from the current commit? I only skimmed the changeset, but it looks like the determination of the current version hasn't changed? |
Ah, right. Well versioned files will be preferred, so now that even go.mod has a version in comment it will usually not be an issue. But it’s definitely still a bug that needs fixing! |
Okiedoke, I fixed the other issue also in #574 using a similar solution—iterate all commits that are reachable in order to figure out which tags are relevant. There's probably a better way to do this, but I don't know it 😅. Again, thinking it's better to fix the bug first and worry about performance as needed. So I think that means that that branch will work for your projects now 🤞 |
I have a branch in which I've created a release
rc
tag. In a completely separate branch, from which therc
tag is not reachable, I'm getting an "inconsistent versions" error that cites therc
tag, sayingFound <rc-tag> which does not match <actual>
(where<rc-tag>
matches the tag that isn't reachable, and<actual>
is the expected version).I can verify that
<actual>
is the most recent reachable tag usinggit describe
:The text was updated successfully, but these errors were encountered: