Skip to content

[ISSUE]: "track-merge-target: false" reads tag from other branch #4795

@Ult0r

Description

@Ult0r

Prerequisites

  • I have written a descriptive issue title
  • I have searched issues to ensure it has not already been reported

GitVersion package

GitVersion.Tool

GitVersion version

6.5.1

Operating system

Windows

What are you seeing?

I want to use the latest tag that is contained on the current branch to be used as the base version. For that I turn track-merge-target off. However, a tag from another branch is being used to calculate the base version (see steps to reproduce).

This could also be intended behavior and I'm understanding the configuration wrong. In that case, please let me know if there is a way to achieve this.

What is expected?

I'd expect the version in the last line to be 1.1.2-alpha-[sha(foobar)], but it is 9.9.10-alpha-[sha(foobar)].

Steps to Reproduce

create an empty directory, then add GitVersion.yml to it:

mode: ContinuousDelivery
assembly-informational-format: '{MajorMinorPatch}{PreReleaseLabelWithDash}-{ShortSha}'
strategies:
- TaggedCommit
branches:
  main:
    increment: None
  develop:
    increment: Patch
    track-merge-target: false

then execute:

git init # current branch is 'master'
git add .
git commit -m "init"
git tag 1.1.1 # tagging "init"
dotnet-gitversion # 1.1.1-[sha(init)]

# create develop branch and add a dummy commit
git checkout -B develop
dotnet-gitversion # 1.1.2-alpha-[sha(init)]
touch foo.txt
git add foo.txt
git commit -m "foo"
dotnet-gitversion # 1.1.2-alpha-[sha(foo)]

# merge develop into master, add a dummy commit to master and tag that new work
git checkout master
git merge develop
dotnet-gitversion # 1.1.1-[sha(foo)]
touch bar.txt
git add bar.txt
git commit -m "bar"
dotnet-gitversion # 1.1.1-[sha(bar)]
git tag 9.9.9 # tagging "bar"
dotnet-gitversion # 9.9.9-[sha(bar)]

# develop now doesn't contain commit "bar" nor tag 9.9.9
git checkout develop
dotnet-gitversion # 1.1.2-alpha-[sha(foo)]

# but if a commit is added it now suddenly takes the tag from the master branch (since it's now 'older')
touch foobar.txt
git add foobar.txt
git commit -m "foobar"
dotnet-gitversion # 9.9.10-alpha-[sha(foobar)]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions