Skip to content

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

Description

@HHobeck

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions