-
Notifications
You must be signed in to change notification settings - Fork 652
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
RFC regarding the calculation of Base Versions #2799
Conversation
src/GitVersion.Core/VersionCalculation/BaseVersionCalculator.cs
Outdated
Show resolved
Hide resolved
I think this is an improvement, but as it is a breaking change, I think we need to postpone this to GitVersion 6. |
That's a fair point; so when is v6 planned for? And what are the next steps to get this in? Also, I'm having some trouble fixing the last 2 failing tests, could someone have a look? |
I think that if you rebase on |
Still seems broken for some other reason :S |
Just a note for your next PR: Create a disposable branch from |
7bd712f
to
86d67b8
Compare
@asbjornu Woo-hoo! Got the merge conflict resolved and the test to turn green! |
I don't mind fixing this merge conflict again, but will it be merged afterwards? Does it need more approvals? |
@ni-fgenois, sorry about not merging this, but as mentioned in #2799 (comment) we need to postpone this to version 6 of GitVersion as it is a breaking change. We don't have a v6 branch yet, but perhaps we should create one so we can merge v6 features like this. Thoughts @arturcic? |
@asbjornu I would go the other way, I'd create a |
Ok, please tell me when the Thank you two for the quick response :) |
Sounds like a plan, @arturcic! 👍🏼 |
The 5.x release seem to have been kicked, is it time to merge this in? (If so, I'll rebase the code and fix the tests) |
@ni-fgenois not yet, I'm working on making the branch |
|
Sorry for the delay, the merge conflict was a bit more challenging this time around. You might want to also take a look to this new test case I have added here : https://github.com/GitTools/GitVersion/pull/2799/files#diff-d43fa8360d2034a4a95db32f5376f489764f0cb4b4ceec376940a7797a699528R205 Thanks for the notification and all the support :) |
Awesome, @ni-fgenois. Thanks! Just one thing I thought when reviewing this is that there has been some discussion leading to #3041 lately. I think this PR affects that and want to have your thoughts on the matter. |
This PR would indeed partially impact that other topic; as we would now be taking versioned tags over any other VersionSources (merge commits, etc). But if there is a case where there are no tags present in the VersionSources, the old behavior will still apply. This relates to another interrogation I had on this topic the other day about the behavior of GitVersion when encoutering tags. I thought that, running GitVersion on a commit with a tag that is a valid SemVer should simply return that version (even when there is some Meta information in the tag). What do you think? I thought this would be a convenient way to lock/override a version (helps with replayability of GitVersion when the CI is automatically tagging the repo). This came to me when dealing with tags on master containing Release Candidate meta information. I wanted to setup automatic tagging on Here's a test that illustrates this scenario : [Test]
public void ShouldUseTheSemVerMetadataOfTags()
{
using var fixture = new EmptyRepositoryFixture();
fixture.Repository.MakeATaggedCommit("1.0.0");
fixture.Repository.MakeCommits(1);
fixture.Repository.CreateBranch("release/2.0.0");
fixture.Checkout("release/2.0.0");
fixture.Repository.MakeCommits(4);
fixture.Checkout(MainBranch);
fixture.Repository.MergeNoFF("release/2.0.0", Generate.SignatureNow());
fixture.AssertFullSemver("2.0.0+0");
fixture.Repository.MakeCommits(1);
fixture.AssertFullSemver("2.0.0+1");
fixture.Repository.ApplyTag("2.0.0+1");
fixture.AssertFullSemver("2.0.0"); // but it should be 2.0.0+1
fixture.Repository.MakeCommits(1);
fixture.AssertFullSemver("2.0.1+1"); // but it should be 2.0.0+2
} |
So, I've updated the failing test specified in #2394 to use the new fixtures (see below), and it seems my PR fixes this behavior (the test below is green on my branch; haven't pushed it though). I haven't found a test case to repro the issue mentioned in : #2394 [Test]
public void VersionSource()
{
using var fixture = new EmptyRepositoryFixture();
fixture.Repository.MakeATaggedCommit("0.1.0");
fixture.Checkout(MainBranch);
fixture.Repository.CreateBranch("develop");
fixture.Checkout("develop");
fixture.MakeACommit("Feature commit 1");
fixture.BranchTo("release/0.2.0");
fixture.MakeACommit("Release commit 1");
fixture.Checkout(MainBranch);
fixture.MergeNoFF("release/0.2.0");
fixture.ApplyTag("0.2.0");
var tag = fixture.Repository.Head.Tip;
fixture.Checkout("develop");
fixture.MergeNoFF(MainBranch);
fixture.AssertFullSemver("0.3.0-alpha.1");
var version = fixture.GetVersion();
version.VersionSourceSha.ShouldBeEquivalentTo(tag.Sha);
} |
That sounds great, @ni-fgenois! Please include the test from #2394 in this PR and write in the description |
Done! :) On another subject, while I've got you here, what do you think of this behavior illustrated above? fixture.AssertFullSemver("2.0.0+1");
fixture.Repository.ApplyTag("2.0.0+1");
fixture.AssertFullSemver("2.0.0"); // shouldn't it be 2.0.0+1? Is there already an explaination for that, or should I open another ticket? |
Great!
I'm not sure there is a good explanation other than that everything after Although I don't think careful consideration has been applied to this behavior, I would dare to say that this is by design and not a bug. Whether the design is correct or not, can of course be discussed. |
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.
The only thing to point out are some minor code style changes. Also, I think it would be great to document how this works once and for all. Could you please attempt to write something up? I'll help with the formulation, but I would appreciate if you could get the ball rolling. 🙏🏼
src/GitVersion.Core/VersionCalculation/BaseVersionCalculator.cs
Outdated
Show resolved
Hide resolved
src/GitVersion.Core/VersionCalculation/BaseVersionCalculator.cs
Outdated
Show resolved
Hide resolved
src/GitVersion.Core/VersionCalculation/BaseVersionCalculator.cs
Outdated
Show resolved
Hide resolved
src/GitVersion.Core/VersionCalculation/BaseVersionCalculator.cs
Outdated
Show resolved
Hide resolved
src/GitVersion.Core/VersionCalculation/BaseVersionCalculator.cs
Outdated
Show resolved
Hide resolved
src/GitVersion.Core/VersionCalculation/BaseVersionCalculator.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: Asbjørn Ulsberg <[email protected]>
Co-authored-by: Asbjørn Ulsberg <[email protected]>
Co-authored-by: Asbjørn Ulsberg <[email protected]>
Co-authored-by: Asbjørn Ulsberg <[email protected]>
Co-authored-by: Asbjørn Ulsberg <[email protected]>
Co-authored-by: Asbjørn Ulsberg <[email protected]>
I believe #3190 touched upon many of the same files as this PR. Can you please rebase and assess whether this PR is relevant and needed anymore? |
To be honest, I kinda lost track of this change over the last couple of months. I'm not even sure if this PR is relevant anymore; I would suggest closing it for now. I can always re-open it if needed. |
Hmm I see... With the refactoring of #3190 the BaseVersionCalculator class has not been survived. That means your refactoring is obsolete IMO. Sorry for that! But if I see your unit tests then this is almost fixed in 6.x and the behavior is like you would expecting it. |
I totally agree with you that the output of GitVersion should yield the same result before and after the tagging has been done. I would go one step further and say: Even if you tag the commit with 2.0.0. |
Please integrate your ideas and help us to realize #3041 and contribute for version 6.x. I'm going to close this PR because it makes no sense anymore. Thank you very very very much for your input and your work. |
Dear Reviewers,
Please take a look at the discussion here : #2798
TL;DR : I'm proposing we use the
BaseVersionSource
ofTags
beforeMergeMessage
, if there are any.I think there might be implications I am not foreseeing and would like your input on this proposition.
Related Issue
Resolves #2798.
Related to #1526.
Fixes #2394.
Checklist: