Skip to content

How to configure GitVersion to work with 'Trunk Based Development' using 'Branch for Release' #3357

Closed
@sheppyh

Description

@sheppyh

Edit: See how to configure this properly here: #3357 (comment)

TLDR: How do I/is it possible to configure GitVersion to work with: https://trunkbaseddevelopment.com/branch-for-release/ when tags only exist on release branches.

Describe the bug
GitVersion ignores tags on release branches, so main/develop are not showing the correct version.
It appears "tracks-release-branches" does nothing - i.e. setting this to true on the master branch doesn't fix the issue.
We use trunk-based development with branch for release - see here: https://trunkbaseddevelopment.com/branch-for-release/
So at some point in development we branch off master into, for example, release-1.0.x and start preparing a release.
All bug fixes are made on master, then cherry-picked into the release branch. These changes are never merged back to master.
When a release is ready, the latest commit on the release branch is tagged, for example 1.0.0

Expected Behavior

At this point, I expect master branch to be showing version 1.1.0

Actual Behavior

Master branch is showing version 0.1.0

Possible Fix

Fix/cause unknown - could be my configuration (this is reproducible with default config, and any configuration I can think of)

Steps to Reproduce

  1. Create a test repository, create a README.md
  2. git commit -m "Initial commit"
  3. Add a file
  4. git commit -m "feat: FirstFeat"
  5. git branch release-1.0.x
  6. git checkout master
  7. Add another file
  8. git commit -m "fix: FirstFix"
  9. git checkout release-1.0.x
  10. git cherry-pick
  11. git tag 1.0.0

Context

Implement gitversion for trunk-based development using Branch for release. Allow developers to continue committing to master by cherry-picking fixes from master into release branch when preparing a release. Tag release branch - master branch shows correct version for next release.

Your Environment

Multiple versions tested, exists in 5.12.0

  • Version Used: 5.12.0
  • Operating System and version (Windows 10, Ubuntu 18.04): Windows Server 2016
  • Link to your project: N/A
  • Link to your CI build (if appropriate): N/A

gitversion /diag:

INFO [01/30/23 15:52:12:53] Dumping commit graph: 
INFO [01/30/23 15:52:12:65] * 9406344 2 minutes ago  (tag: 1.0.0, release-1.0.x)
| * 04f5a1c 3 minutes ago  (HEAD -> master)
|/  
* 0e56ce9 4 minutes ago 
* 358ef40 4 minutes ago 

INFO [01/30/23 15:52:12:65] Working directory: C:\Users\admin-hjohn\Desktop\Git\VersionControlTesting4
INFO [01/30/23 15:52:12:73] Branch from build environment: 
INFO [01/30/23 15:52:12:74] Project root is: C:\Users\admin-hjohn\Desktop\Git\VersionControlTesting4\
INFO [01/30/23 15:52:12:74] DotGit directory is: C:\Users\admin-hjohn\Desktop\Git\VersionControlTesting4\.git
INFO [01/30/23 15:52:12:82] Using latest commit on specified branch
INFO [01/30/23 15:52:12:90] Running against branch: master (04f5a1c fix: FirstFix)
INFO [01/30/23 15:52:12:90] Begin: Calculating base versions
  INFO [01/30/23 15:52:12:92] Fallback base version: 0.1.0 with commit count source 358ef4054a7e6d992131d052fe97708e9eab1eaa
  INFO [01/30/23 15:52:13:06] Found multiple base versions which will produce the same SemVer (0.1.0), taking oldest source for commit counting (Fallback base version)
  INFO [01/30/23 15:52:13:06] Base version used: Fallback base version: 0.1.0 with commit count source 358ef4054a7e6d992131d052fe97708e9eab1eaa
  INFO [01/30/23 15:52:13:06] End: Calculating base versions (Took: 162.88ms)
  INFO [01/30/23 15:52:13:07] 2 commits found between 358ef40 Initial commit and 04f5a1c fix: FirstFix
  INFO [01/30/23 15:52:13:07] Skipping version increment
  INFO [01/30/23 15:52:13:07] 2 commits found between 358ef40 Initial commit and 04f5a1c fix: FirstFix
Executing GenerateSetVersionMessage for 'LocalBuild'.

Executing GenerateBuildLogOutput for 'LocalBuild'.
{
  "Major": 0,
  "Minor": 1,
  "Patch": 0,

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions