Skip to content

[Bug] Closing pull request from hotfix to support failed to inherit Increment branch configuration #3020

@micdenny

Description

@micdenny

The version chosen when closing a pull request from hotfix branch to support branch is wrong because gitversion doesn't choose the right parent branch.

GitVersion.yml

mode: ContinuousDeployment
branches:
  master:
    tag: beta
    increment: Minor
  pull-request:
    tag: alpha-pr
  support:
    tag: beta
ignore:
  sha: []
merge-message-formats: {}

I have a couple of case that you can look at it.

case 1 remote + local branches

image

WARN [02/28/22 16:27:04:24] Failed to inherit Increment branch configuration, ended up with: support/v1.0.x, origin/hotfix/v1.0.2
Falling back to master branch config

case 2 remote/local only

image

WARN [02/28/22 16:13:00:16] Failed to inherit Increment branch configuration, ended up with: master, support/v1.0.x
Falling back to master branch config

The pull/x/merge is the branch that is automatically created from azure devops pull request, and the build pipeline use that branch to build from, and I would like to have a proper version even in that case to generate a very early pre-release version.

Expected Behavior

case 1 remote + local branches

"FullSemVer": "1.0.2-alpha-pr0002.2"

case 2 remote/local only

"FullSemVer": "1.0.1-alpha-pr0002.2"

Actual Behavior

case 1 remote + local branches

"FullSemVer": "1.1.0-alpha-pr0002.3"

case 2 remote/local only

"FullSemVer": "1.1.0-alpha-pr0002.2"

Steps to Reproduce

case 1 remote + local branches

git init remote-case1
cd remote-case1

# create a file GitVersion.yml using the configuration up above

git add .
git commit -m "First commit"
git tag -a -m "Release v1.0.0" v1.0.0
git commit --allow-empty -m "Merged PR 1: new feature"
git checkout tags/v1.0.0 -b support/v1.0.x
git commit --allow-empty -m "hotfix 1"
git tag -a -m "Release v1.0.1" v1.0.1
git checkout -b hotfix/v1.0.2
git commit --allow-empty -m "hotfix 2"
git checkout support/v1.0.x
git checkout -b pull/2/merge
git merge --no-ff -m "Merge pull request 2 from hotfix/v1.0.2 into support/v1.0.x"  hotfix/v1.0.2

cd ..
git clone remote-case1 local-case1
cd local-case1
git checkout master
git checkout support/v1.0.x
git checkout hotfix/v1.0.2
git checkout pull/2/merge

# dotnet gitversion /nocache /output json /output buildserver
# gitversion response is wrong 1.1.0-alpha-pr0002.3 expected 1.0.2-alpha-pr0002.2

case 2 remote/local only

git init remote-case2
cd remote-case2

# create a file GitVersion.yml using the configuration up above

git add .
git commit -m "First commit"
git tag -a -m "Release v1.0.0" v1.0.0
git commit --allow-empty -m "Merged PR 1: new feature"
git checkout tags/v1.0.0 -b support/v1.0.x
git checkout -b hotfix/v1.0.1
git commit --allow-empty -m "hotfix"
git checkout support/v1.0.x
git checkout -b pull/2/merge
git merge --no-ff -m "Merge pull request 2 from hotfix/v1.0.1 into support/v1.0.x"  hotfix/v1.0.1

# dotnet gitversion /nocache /output json /output buildserver
# gitversion response is wrong 1.1.0-alpha-pr0002.2 expected 1.0.1-alpha-pr0002.2

Your Environment

  • Version Used: 5.10.3+Branch.support-5.x.Sha.bc9c9d003e655385e3dd1ba3bd013e04062d2f9b
  • Operating System and version: Windows 10 21H2 (19044.1566)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions