question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Mainline Not Incrementing SemVer

See original GitHub issue

I’m trying to setup GitVersion and running in to an issue with generating the correct SemVer values. It is possible I just don’t understand how it is supposed to work as I am new to this tool.

Here are the steps I took:

  • Added a version tag to the Main branch (1.0.5)
  • Created a new feature branch from main (feature/azure-devops)
  • Merged the feature branch to main

When calculating the version for the feature branch it looks correct. I get a version of 1.0.5-azure-devops.10 After merging the feature branch to main the calculated version is 1.0.5 and it should be 1.0.6 or rather 1.1.0 since this was a feature branch.

Here is my config:

next-version: 1.0
mode: Mainline
increment: Inherit
update-build-number: true
branches:
  main:
    regex: ^main$
    is-mainline: true

Here are the logs for the run after merging the feature branch to main:

INFO [01/04/22 17:56:51:81] Begin: Calculating base versions
    INFO [01/04/22 17:56:51:83] NextVersion in GitVersion configuration file: 1.0.0 with commit count source External Source
    INFO [01/04/22 17:56:51:85] Fallback base version: 0.1.0 with commit count source 94f8b33052712e905160b3056
    INFO [01/04/22 17:56:51:88] Git tag 'v1.0.5': 1.0.5 with commit count source a4b457d1029cb00d01adc
    INFO [01/04/22 17:56:51:88] Git tag 'v1.0.4.2': 1.0.4+2 with commit count source 5e1e5937323357620da2db3afcdd
    INFO [01/04/22 17:56:51:92] Found multiple base versions which will produce the same SemVer (1.0.6), taking oldest source for commit counting (Git tag 'v1.0.5')
    INFO [01/04/22 17:56:51:92] Base version used: Git tag 'v1.0.5': 1.0.5 with commit count source a4b457d1029cb00d01adc
  INFO [01/04/22 17:56:51:92] End: Calculating base versions (Took: 111.30ms)
  INFO [01/04/22 17:56:51:92] 2 commits found between a4b457d Merge branch 'feature/azure-devops' into 'main' and 01649a5 Merge branch 'feature/azure-devops' into 'main'
  INFO [01/04/22 17:56:51:93] Begin: Using mainline development mode to calculate current version
    INFO [01/04/22 17:56:51:94] Found possible mainline branches: main
    INFO [01/04/22 17:56:51:94] Mainline for current branch is main
    INFO [01/04/22 17:56:51:94] 2 commits found between a4b457d Merge branch 'feature/azure-devops' into 'main' and 01649a5 Merge branch 'feature/azure-devops' into 'main'
  INFO [01/04/22 17:56:51:94] End: Using mainline development mode to calculate current version (Took: 16.99ms)
  INFO [01/04/22 17:56:51:95] Begin: Creating dictionary
  INFO [01/04/22 17:56:51:95] End: Creating dictionary (Took: 4.89ms)
  INFO [01/04/22 17:56:51:95] Begin: Storing version variables to cache file D:\a\1\s\.git\gitversion_cache\9506D992C48C14BD0BC2C0F585BFC5F2F0AA2B5B.yml
  INFO [01/04/22 17:56:51:99] End: Storing version variables to cache file D:\a\1\s\.git\gitversion_cache\9506D992C48C14BD0BC2C0F585BFC5F2F0AA2B5B.yml (Took: 39.91ms)
Executing GenerateSetVersionMessage for 'AzurePipelines'.
Executing GenerateBuildLogOutput for 'AzurePipelines'.
{
  "Major": 1,
  "Minor": 0,
  "Patch": 5,
  "PreReleaseTag": "2",
  "PreReleaseTagWithDash": "",
  "PreReleaseLabel": "",
  "PreReleaseLabelWithDash": "",
  "PreReleaseNumber": null,
  "WeightedPreReleaseNumber": 60000,
  "BuildMetaData": null,
  "BuildMetaDataPadded": "",
  "FullBuildMetaData": "Branch.main.Sha.01649a5c492989d099a45ea0ddbc",
  "MajorMinorPatch": "1.0.5",
  "SemVer": "1.0.5",
  "LegacySemVer": "1.0.5",
  "LegacySemVerPadded": "1.0.5",
  "AssemblySemVer": "1.0.5.0",
  "AssemblySemFileVer": "1.0.5.0",
  "FullSemVer": "1.0.5",
  "InformationalVersion": "1.0.5+Branch.main.Sha.01649a5c492989d099a45ea0ddbc",
  "BranchName": "main",
  "EscapedBranchName": "main",
  "Sha": "01649a5c492989d099a45ea0ddbc",
  "ShortSha": "01649a5",
  "NuGetVersionV2": "1.0.5",
  "NuGetVersion": "1.0.5",
  "NuGetPreReleaseTagV2": "",
  "NuGetPreReleaseTag": "",
  "VersionSourceSha": "a4b457d1029cb00d01adc",
  "CommitsSinceVersionSource": 2,
  "CommitsSinceVersionSourcePadded": "0002",
  "UncommittedChanges": 0,
  "CommitDate": "2022-01-04"
}

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:17 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
jpodobacommented, Jan 10, 2023

The best for me fit the solution with pull_request template messages. It’s not ideal because requires additional effort and updates each repo but works with squash merges and Mainline mode used in our approach.

That was described here if someone will need it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[Bug] GitVersion not incrementing anymore · Issue #2467
After my merge with my new code, I added +semver:patch to increment the patch version from 4.0.26 to 4.0.27. Actual Behavior. The versioning ......
Read more >
GitVersion configuration is not incrementing
I'm trying to setup GitVersion to handle our project's semantic versioning (GitFlow), but it's not incrementing automatically as I'm expecting.
Read more >
Version Incrementing
Semantic Versioning is all about releases, not commits or builds. This means that the version only increases after you release, this directly conflicts...
Read more >
How to use GitVersion to get sensible versioning
Just like we saw on the develop branch, a part of the version increments with each commit on that branch. But since adding...
Read more >
Mainline Development
If you do not want GitVersion to treat a commit or a pull request as a release and increment the version you can...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found