Skip to content
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

[Bug] Consider pre-release tags only when they matching with the label name on branch #3438

Closed
HHobeck opened this issue Mar 13, 2023 · 4 comments · Fixed by #3441
Closed
Labels
Milestone

Comments

@HHobeck
Copy link
Contributor

HHobeck commented Mar 13, 2023

Describe the bug
When defining a label on e.g. main branch and one or more pre-release labeled tags are existing then I would expect that only the pre-release tags are considered with the same name.

This issue is related to #3436.

Expected Behavior

[TestCase(1)]
[TestCase(2)]
public void ExpectedBehavior(long patchNumber)
{
    var configuration = GitHubFlowConfigurationBuilder.New
        .WithBranch("main", branchBuilder => branchBuilder
            .WithVersioningMode(VersioningMode.ContinuousDelivery)
            .WithLabel(string.Empty).WithIncrement(IncrementStrategy.Patch)
        ).Build();

    using var fixture = new EmptyRepositoryFixture("main");

    fixture.MakeACommit();

    // ✅ succeeds as expected
    fixture.AssertFullSemver($"0.0.1+1", configuration);

    fixture.ApplyTag($"0.0.{patchNumber}-alpha.1");

    // ✅ succeeds as expected
    fixture.AssertFullSemver($"0.0.{patchNumber}+1", configuration);

    fixture.MakeACommit();

    // ✅ succeeds as expected
    fixture.AssertFullSemver($"0.0.{patchNumber}+2", configuration);

    fixture.MakeACommit();

    // ✅ succeeds as expected
    fixture.AssertFullSemver($"0.0.{patchNumber}+3", configuration);

    fixture.MakeATaggedCommit($"0.0.{patchNumber}-beta.1");

    // ✅ succeeds as expected
    fixture.AssertFullSemver($"0.0.{patchNumber}+4", configuration);

    fixture.MakeACommit();

    // ✅ succeeds as expected
    fixture.AssertFullSemver($"0.0.{patchNumber}+5", configuration);

    fixture.MakeATaggedCommit($"0.0.{patchNumber}-beta.2");

    // ✅ succeeds as expected
    fixture.AssertFullSemver($"0.0.{patchNumber}+6", configuration);

    fixture.MakeACommit();

    // ✅ succeeds as expected
    fixture.AssertFullSemver($"0.0.{patchNumber}+7", configuration);

    fixture.ApplyTag($"0.0.{patchNumber}");

    // ✅ succeeds as expected
    fixture.AssertFullSemver($"0.0.{patchNumber}", configuration);

    fixture.MakeACommit();

    // ✅ succeeds as expected
    fixture.AssertFullSemver($"0.0.{patchNumber + 1}+1", configuration);
}

Actual Behavior

[TestCase(1)]
[TestCase(2)]
public void ActualBehavior(long patchNumber)
{
    var configuration = GitHubFlowConfigurationBuilder.New
        .WithBranch("main", branchBuilder => branchBuilder
            .WithVersioningMode(VersioningMode.ContinuousDelivery)
            .WithLabel(string.Empty).WithIncrement(IncrementStrategy.Patch)
        ).Build();

    using var fixture = new EmptyRepositoryFixture("main");

    fixture.MakeACommit();

    // ✅ succeeds as expected
    fixture.AssertFullSemver("0.0.1+1", configuration);

    fixture.ApplyTag($"0.0.{patchNumber}-alpha.1");

    // ❌ expected: 0.0.{patchNumber}+1
    fixture.AssertFullSemver($"0.0.{patchNumber}+0", configuration);

    fixture.MakeACommit();

    // ❌ expected: 0.0.{patchNumber}+2
    fixture.AssertFullSemver($"0.0.{patchNumber}+1", configuration);

    fixture.MakeACommit();

    // ❌ expected: 0.0.{patchNumber}+3
    fixture.AssertFullSemver($"0.0.{patchNumber}+2", configuration);

    fixture.MakeATaggedCommit($"0.0.{patchNumber}-beta.1");

    // ❌ expected: 0.0.{patchNumber}+4
    fixture.AssertFullSemver($"0.0.{patchNumber}+0", configuration);

    fixture.MakeACommit();

    // ❌ expected: 0.0.{patchNumber}+5
    fixture.AssertFullSemver($"0.0.{patchNumber}+1", configuration);

    fixture.MakeATaggedCommit($"0.0.{patchNumber}-beta.2");

    // ❌ expected: 0.0.{patchNumber}+6
    fixture.AssertFullSemver($"0.0.{patchNumber}+0", configuration);

    fixture.MakeACommit();

    // ❌ expected: 0.0.{patchNumber}+7
    fixture.AssertFullSemver($"0.0.{patchNumber}+1", configuration);

    fixture.ApplyTag($"0.0.{patchNumber}");

    // ✅ succeeds as expected
    fixture.AssertFullSemver($"0.0.{patchNumber}", configuration);

    fixture.MakeACommit();

    // ✅ succeeds as expected
    fixture.AssertFullSemver($"0.0.{patchNumber + 1}+1", configuration);
}

Possible Fix

The business logic how the pre-release label are created needs to be changed in NextVersionCalculator::FindVersion

Steps to Reproduce

Please see the integration tests above.

Context

Your Environment

I have used the 6.0.0-beta.1 version

@HHobeck HHobeck added the bug label Mar 13, 2023
@HHobeck HHobeck added this to the 6.x milestone Mar 13, 2023
@HHobeck
Copy link
Contributor Author

HHobeck commented Mar 15, 2023

[TestCase(1)]
[TestCase(2)]
[TestCase(3)]
public void EnsurePreReleaseTagLabelWillBeConsideredIfAlphaLabelIsDefined(long patchNumber)
{
    var configuration = GitHubFlowConfigurationBuilder.New
        .WithLabel(null)
        .WithBranch("main", branchBuilder => branchBuilder
            .WithVersioningMode(VersioningMode.ContinuousDelivery)
            .WithLabel("alpha").WithIncrement(IncrementStrategy.Patch)
        ).Build();

    using var fixture = new EmptyRepositoryFixture("main");

    fixture.MakeACommit();

    // ✅ succeeds as expected
    fixture.AssertFullSemver("0.0.1-alpha.1+1", configuration);

    fixture.ApplyTag($"0.0.{patchNumber}-alpha.1");

    // ✅ succeeds as expected
    fixture.AssertFullSemver($"0.0.{patchNumber}-alpha.1", configuration);

    fixture.MakeACommit();

    // ✅ succeeds as expected
    fixture.AssertFullSemver($"0.0.{patchNumber}-alpha.2+1", configuration);

    fixture.MakeACommit();

    // ✅ succeeds as expected
    fixture.AssertFullSemver($"0.0.{patchNumber}-alpha.2+2", configuration);

    fixture.MakeATaggedCommit($"0.0.{patchNumber}-beta.1");

    // ❌ expected: 0.0.{patchNumber}-alpha.2+3
    fixture.AssertFullSemver($"0.0.{patchNumber}-alpha.2+0", configuration);

    fixture.MakeACommit();

    // ❌ expected: 0.0.{patchNumber}-alpha.2+4
    fixture.AssertFullSemver($"0.0.{patchNumber}-alpha.2+1", configuration);

    fixture.MakeATaggedCommit($"0.0.{patchNumber}-beta.2");

    // ❌ expected: 0.0.{patchNumber}-alpha.2+5
    fixture.AssertFullSemver($"0.0.{patchNumber}-alpha.2+0", configuration);

    fixture.MakeACommit();

    // ❌ expected: 0.0.{patchNumber}-alpha.2+6
    fixture.AssertFullSemver($"0.0.{patchNumber}-alpha.2+1", configuration);

    fixture.ApplyTag($"0.0.{patchNumber}");

    // ❌ expected: 0.0.{patchNumber}
    fixture.AssertFullSemver($"0.0.{patchNumber}-alpha.1+0", configuration);

    fixture.MakeACommit();

    // ✅ succeeds as expected
    fixture.AssertFullSemver($"0.0.{patchNumber + 1}-alpha.1+1", configuration);

    fixture.Repository.DumpGraph();
}

@HHobeck
Copy link
Contributor Author

HHobeck commented Mar 15, 2023

[TestCase(1)]
[TestCase(2)]
[TestCase(3)]
public void EnsurePreReleaseTagLabelWillBeConsideredIfBetaLabelIsDefined(long patchNumber)
{
    var configuration = GitHubFlowConfigurationBuilder.New
        .WithBranch("main", branchBuilder => branchBuilder
            .WithVersioningMode(VersioningMode.ContinuousDelivery)
            .WithLabel("beta").WithIncrement(IncrementStrategy.Patch)
        ).Build();

    using var fixture = new EmptyRepositoryFixture("main");

    fixture.MakeACommit();

    // ✅ succeeds as expected
    fixture.AssertFullSemver("0.0.1-beta.1+1", configuration);

    fixture.ApplyTag($"0.0.{patchNumber}-alpha.1");

    // ❌ expected: 0.0.{patchNumber}-beta.1+1
    fixture.AssertFullSemver($"0.0.{patchNumber}-beta.1+0", configuration);

    fixture.MakeACommit();

    // ❌ expected: 0.0.{patchNumber}-beta.1+2
    fixture.AssertFullSemver($"0.0.{patchNumber}-beta.1+1", configuration);

    fixture.MakeACommit();

    // ❌ expected: 0.0.{patchNumber}-beta.1+3
    fixture.AssertFullSemver($"0.0.{patchNumber}-beta.1+2", configuration);

    fixture.MakeATaggedCommit($"0.0.{patchNumber}-beta.1");

    // ✅ succeeds as expected
    fixture.AssertFullSemver($"0.0.{patchNumber}-beta.1", configuration);

    fixture.MakeACommit();

    // ✅ succeeds as expected
    fixture.AssertFullSemver($"0.0.{patchNumber}-beta.2+1", configuration);

    fixture.MakeATaggedCommit($"0.0.{patchNumber}-beta.2");

    // ✅ succeeds as expected
    fixture.AssertFullSemver($"0.0.{patchNumber}-beta.2", configuration);

    fixture.MakeACommit();

    // ✅ succeeds as expected
    fixture.AssertFullSemver($"0.0.{patchNumber}-beta.3+1", configuration);

    fixture.ApplyTag($"0.0.{patchNumber}");

    // ❌ expected: 0.0.{patchNumber}
    fixture.AssertFullSemver($"0.0.{patchNumber}-beta.2+0", configuration);

    fixture.MakeACommit();

    // ✅ succeeds as expected
    fixture.AssertFullSemver($"0.0.{patchNumber + 1}-beta.1+1", configuration);
}

@HHobeck
Copy link
Contributor Author

HHobeck commented Mar 15, 2023

[TestCase(1)]
[TestCase(2)]
[TestCase(3)]
public void EnsurePreReleaseTagLabelWillBeConsideredIfGammaLabelIsDefined(long patchNumber)
{
    var configuration = GitHubFlowConfigurationBuilder.New
        .WithBranch("main", branchBuilder => branchBuilder
            .WithVersioningMode(VersioningMode.ContinuousDelivery)
            .WithLabel("gamma").WithIncrement(IncrementStrategy.Patch)
        ).Build();

    using var fixture = new EmptyRepositoryFixture("main");

    fixture.MakeACommit();

    // ✅ succeeds as expected
    fixture.AssertFullSemver("0.0.1-gamma.1+1", configuration);

    fixture.ApplyTag($"0.0.{patchNumber}-alpha.1");

    // ❌ expected: 0.0.{patchNumber}-gamma.1+1
    fixture.AssertFullSemver($"0.0.{patchNumber}-gamma.1+0", configuration);

    fixture.MakeACommit();

    // ❌ expected: 0.0.{patchNumber}-gamma.1+2
    fixture.AssertFullSemver($"0.0.{patchNumber}-gamma.1+1", configuration);

    fixture.MakeACommit();

    // ❌ expected: 0.0.{patchNumber}-gamma.1+3
    fixture.AssertFullSemver($"0.0.{patchNumber}-gamma.1+2", configuration);

    fixture.MakeATaggedCommit($"0.0.{patchNumber}-beta.1");

    // ❌ expected: 0.0.{patchNumber}-gamma.1+4
    fixture.AssertFullSemver($"0.0.{patchNumber}-gamma.1+0", configuration);

    fixture.MakeACommit();

    // ❌ expected: 0.0.{patchNumber}-gamma.1+5
    fixture.AssertFullSemver($"0.0.{patchNumber}-gamma.1+1", configuration);

    fixture.MakeATaggedCommit($"0.0.{patchNumber}-beta.2");

    // ❌ expected: 0.0.{patchNumber}-gamma.1+6
    fixture.AssertFullSemver($"0.0.{patchNumber}-gamma.1+0", configuration);

    fixture.MakeACommit();

    // ❌ expected: 0.0.{patchNumber}-gamma.1+7
    fixture.AssertFullSemver($"0.0.{patchNumber}-gamma.1+1", configuration);

    fixture.ApplyTag($"0.0.{patchNumber}");

    // ✅ succeeds as expected
    fixture.AssertFullSemver($"0.0.{patchNumber}", configuration);

    fixture.MakeACommit();

    // ✅ succeeds as expected
    fixture.AssertFullSemver($"0.0.{patchNumber + 1}-gamma.1+1", configuration);
}

@arturcic
Copy link
Member

arturcic commented Apr 6, 2023

🎉 This issue has been resolved in version 6.0.0-beta.2 🎉
The release is available on:

Your GitReleaseManager bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants