2
votes

The problem:
Until two days ago the version generated by GitVersion worked correctly but now suddenly it rolled from 1.421 to 1.407.

enter image description here

My Environment:

Azure DevOps:

Multiple version of Azure DevOps build pipelines that build 10+ NuGet packages that use GitVersion MsBuild task with Mainline mode configured.

For my build pipelines versions I have the following structure: A version for Microsoft Hosted agent and a version of Self Hosted agent.

For each version I have the following pipelines:
- Restore, Build, Pack, Unit Test and Publish Symbols and to NuGet feed.
- Restore, Build, Pack, Publish
- Restore, Build, Unit Test


GitVersion 5.3.0
I have set it to increment the Minor number for each new commit into my master branch. Also worth to I don't use any other sources for calculating the version as this is the most comfortable approach for me and worked pretty nice until now.

GitVersion yml config:

next-version: 1.1
mode: Mainline
branches: 
  feature:
    tag: alpha
    increment: Inherit
  master:
   increment: Minor
   tag: ''
ignore:
  sha: []
merge-message-formats: {}

What I've tried to do:
- From reading the logs I noticed that Git Version outputs this message: "Skipping fetching, if GitVersion does not calculate your version as expected you might need to allow fetching or use dynamic repositories.", so i used dynamic repositories but the same result is generated.. :(

I don't know what else I should do to debug this.. I'm thinking is a problem with the GitVersion cache?


Thanks in advance.

2
Which branch are we looking at here? What was the change in Git for version 1.407.? Just a regular commit, or was it a merge? What else might have happened in the Git repository between version 1.421. and 1.407.? Any other merges that might have happened? Also, have you tried the latest version of GitVersion?Asbjørn Ulsberg
Hi David, any update for this issue? Does my answer work for you?LoLance
Hello, I'm sorry but due to bank holiday I didn't had access to my work computer.David
@Asbjørn Ulsber master branch, just a regular commit and didn't update to the last version :)David

2 Answers

1
votes

I found the source for my problem. I was working in my project and committed a change before pulling the latest changes from master. Next after pulling the changes I observed that my commit was placed like 6 or 7 commits back in history.

1
votes

I don't know what else I should do to debug this.. I'm thinking is a problem with the GitVersion cache?

1.If the #1.421 and following #1.407 in your pic are both master branch:

I think there's possibility that you have git reset --hard or other action recently in your git repo which caused this behavior:

enter image description here

2.If the #1.421 and following #1.407 in your pic are not for same branch, then it's expected behavior cause the version number is different per branch.(The master and feature have different rules)

enter image description here

The version of the pipeline is next-version: 1.1+ number of valid commits (total commits-the commits deleted during git reset) for one branch. So you need to check:

1.if you modify the version in GitVersion yml recently

2.if you do git reset --hard action recently

3.if the two versions come from two difference branches, the feature branch and master branch have different commits history and different numbers of commits. So it's expected behavior to see different version.