-
Notifications
You must be signed in to change notification settings - Fork 653
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
When incrementing version using commit message, we only consider tags with a valid version #3759
When incrementing version using commit message, we only consider tags with a valid version #3759
Conversation
cfc4bc2
to
e2365d9
Compare
So far your PR looks good. The following use cases coming to my mind:
|
Is what you describe the expected behavior? In main branch as it stands now it works differently: |
Actually the desired behaviour is to use the label as pre-release name if not set to null. Can you try this? var configuration = GitFlowConfigurationBuilder.New.WithLabel(null).WithBranch("main", _ => _.WithLabel(null)).Build() Please see the following unit tests: |
@adaskos-signal: If you take this integration tests you will see that your PR needs lets say a little bit fine tuning ;): [TestCase("", null, "1.9.0-1", "2.0.0-1+1", ExpectedResult = "1.9.0-1")]
[TestCase("", "", "1.9.0-1", "2.0.0-1+1", ExpectedResult = "1.9.0-1")]
[TestCase("", "foo", "1.9.0-1", "2.0.0-foo.1+1", ExpectedResult = "2.0.0-foo.1+1")]
[TestCase("", "bar", "1.9.0-1", "2.0.0-bar.1+1", ExpectedResult = "2.0.0-bar.1+1")]
[TestCase("prefix", null, "1.9.0-1", "2.0.0-1+1", ExpectedResult = "2.0.0-1+1")]
[TestCase("prefix", "", "1.9.0-1", "2.0.0-1+1", ExpectedResult = "2.0.0-1+1")]
[TestCase("prefix", "foo", "1.9.0-1", "2.0.0-foo.1+1", ExpectedResult = "2.0.0-foo.1+1")]
[TestCase("prefix", "bar", "1.9.0-1", "2.0.0-bar.1+1", ExpectedResult = "2.0.0-bar.1+1")]
[TestCase("", null, "2.1.0-1", "2.0.0-1+1", ExpectedResult = "2.1.0-1")]
[TestCase("", "", "2.1.0-1", "2.0.0-1+1", ExpectedResult = "2.1.0-1")]
[TestCase("", "foo", "2.1.0-1", "2.0.0-foo.1+1", ExpectedResult = "2.1.0-foo.1+1")]
[TestCase("", "bar", "2.1.0-1", "2.0.0-bar.1+1", ExpectedResult = "2.1.0-bar.1+1")]
[TestCase("prefix", null, "2.1.0-1", "2.0.0-1+1", ExpectedResult = "2.0.0-1+1")]
[TestCase("prefix", "", "2.1.0-1", "2.0.0-1+1", ExpectedResult = "2.0.0-1+1")]
[TestCase("prefix", "foo", "2.1.0-1", "2.0.0-foo.1+1", ExpectedResult = "2.0.0-foo.1+1")]
[TestCase("prefix", "bar", "2.1.0-1", "2.0.0-bar.1+1", ExpectedResult = "2.0.0-bar.1+1")]
public string WhenTaggingACommitAsPreRelease(string tagPrefix, string? label, string tag, string expectedVersion)
{
var configuration = GitFlowConfigurationBuilder.New.WithLabel(null).WithTagPrefix(tagPrefix)
.WithBranch("main", _ => _.WithLabel(label).WithVersioningMode(VersioningMode.ContinuousDelivery))
.Build();
using EmptyRepositoryFixture fixture = new("main");
fixture.MakeATaggedCommit($"{tagPrefix}1.0.0");
fixture.MakeACommit("+semver:major");
fixture.AssertFullSemver(expectedVersion, configuration);
fixture.ApplyTag(tag);
return fixture!.GetVersion(configuration).FullSemVer;
} |
0debb99
to
aefb1fa
Compare
Description
Changed method
FindCommitMessageIncrement
inIncrementStrategyFinder
to consider SHA from tags that have semantic versioning, by reusingGetTaggedSemanticVersions
ofIRepositoryStore
.The change requires removing the
tagsShaCache
since the discovery must account for the currently usedconfiguration
and its prefix.Related Issue
See issue #3757
Motivation and Context
The current behavior won't allow any other tagging (by the CI or users) to co-exist with version bumping commits.
The problem appears when any of the commits attempting to bump the version come before a tag that is not version related.
The current implementation will ignore those commits, assuming it will find a version forcing tag, when in reality there's no version defined in it.
How Has This Been Tested?
Added a new theory in
VersionBumpingScenarios.cs
with 5 test cases covering prefixed versions too.Checklist: