Skip to content

[Bug] Version isn't incremented because of "Mainline" mode #2940

@taodongl

Description

@taodongl

We are using GitVersion.yml

mode: Mainline
next-version: 1.0
major-version-bump-message: 'BREAKING CHANGE:? *(\(.*\))?: '
minor-version-bump-message: '(feature|feat):? *(\(.*\))?: '
patch-version-bump-message: '.*:? *(\(.*\))?: '

5.2.4 is the latest workable version. From 5.3.0 to current release, the version calculated by gitversion can't get a newer value.


We know branch can't be configured as "Mainline", because:

    private static void VerifyReadConfig(Config config)
    {
        // Verify no branches are set to mainline mode
        if (config.Branches.Any(b => b.Value?.VersioningMode == VersioningMode.Mainline))
        {
            throw new ConfigurationException(@"Mainline mode only works at the repository level, a single branch cannot be put into mainline mode

This is because mainline mode treats your entire git repository as an event source with each merge into the 'mainline' incrementing the version.

If the docs do not help you decide on the mode open an issue to discuss what you are trying to do.");
        }
    }

Thought the document said By default, GitVersion is set up to do Continuous Delivery on all branches but develop,
But when general mode is "Mainline", and mode of branch is null, mode of branch would be set to "Mainline"

Gitversion Code

    private static void FinalizeBranchConfiguration(Config config, string name, BranchConfig? branchConfig)
    {
        ......

        if (branchConfig.VersioningMode == null)
        {
            if (name == Config.DevelopBranchKey)
            {
                branchConfig.VersioningMode = config.VersioningMode == VersioningMode.Mainline ? VersioningMode.Mainline : VersioningMode.ContinuousDeployment;
            }
            else
            {
                branchConfig.VersioningMode = config.VersioningMode; // ---> mode of branch become "Mainline"
            }
        }
        ... ...
    }

I think the above code causes the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions