Skip to content

[Bug] GetReleaseBranchConfig returns only a single config #3050

@Turnerj

Description

@Turnerj

Describe the bug

In 666bd37, to support nullable reference types, a change was made to GetReleaseBranchConfig however it did more than support nullable reference types - it actually changed the behaviour of the method. Previously the method would return all release branch configs however now it only returns the first. This is a problem if you have more than one release branch config set.

Expected Behavior

The method to return a list of all release branch configurations.

Actual Behavior

The method returns a list with only the first found release branch configuration.

Possible Fix

Mostly revert back to the previous code though without the ? checks so the values are compatible with nullable reference type checks.

    public static List<KeyValuePair<string, BranchConfig>> GetReleaseBranchConfig(this Config configuration) =>
        configuration.Branches
            .Where(b => b.Value.IsReleaseBranch == true)
            .ToList();

Steps to Reproduce

public void GetReleaseBranchConfigReturnsAllReleaseBranches()
{
    var config = new Config()
    {
        Branches = new Dictionary<string, BranchConfig>
        {
            { "foo", new BranchConfig { Name = "foo" } },
            { "bar", new BranchConfig { Name = "bar", IsReleaseBranch = true } },
            { "baz", new BranchConfig { Name = "baz", IsReleaseBranch = true } }
        }
    };

    var result = config.GetReleaseBranchConfig();

    result.Count.ShouldBe(2);
    result.ShouldNotContain(b => b.Key == "foo");
}
  1. Have more than one release branch configured
  2. Call the method and have it not return all the release branch configs

Context

We have multiple release branches and the change in behaviour inadvertently made our version numbers wrong.

Your Environment

  • Version Used: 5.9.0

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