Skip to content

[Bug] Mainline mode breaks hotfix version when commit is tagged #2786

Closed
@koershov

Description

@koershov

Describe the bug
When I use mainline mode with master and hotfix branch it works fine unless I start tagging every commit.
Imagine a hotfix branch is branched out from the mainline at version 1.2.0. From that point, every commit on that branch should increment only the patch version. But if one of the commits on hotfix was tagged with current version the next version calculation will be broken (the minor version will be affected by an unrelated commit on mainline)
Here's an example how the git structure for that case looks like

* 45d2cdf 44 minutes ago  (HEAD -> hotfix/may)
* a756535 46 minutes ago  (tag: 1.2.2)
* 104d39d 48 minutes ago 
| * b6e989c 50 minutes ago  (main)
|/  
* 1a4437e 52 minutes ago 
* 6ef88f0 54 minutes ago  (tag: 1.1.0)
* 0ad3ed8 56 minutes ago  (tag: 1.0.0)
* eb7857c 58 minutes ago 

The same thing happens when the commit where the hotfix branch was branched of is tagged

* 5b74598 50 minutes ago  (HEAD -> hotfix/may)
| * 5a68be2 52 minutes ago  (main)
|/  
* d44f7f1 54 minutes ago  (tag: 1.1.0)
* 7784f67 56 minutes ago  (tag: 1.0.0)
* 6d36b75 58 minutes ago 

Expected Behavior

First example, the version should be "1.2.3"
Second example, the version should be "1.1.1"

Actual Behavior

First example, the version should is "1.3.1"
Second example, the version should be "1.2.1"

Possible Fix

It feels like mainlineCommitLog should include also the commit where the current branch was branched off. In FindMergeBaseBeforeForwardMerge method

Steps to Reproduce

Tests are here #2787

Context

Our strategy is very simple. Each commit on main should increment minor. Each commit on hotfix should increment patch.

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