Reputation: 101
Running GitVersion via AzureDevops and receive the following error message when attempting to use on any branch except master (incl, pull request branches, etc.);
So far i've tried to resolve the issue via:
Error:
Gitversion could not determine which branch to treat as the development branch
Git Version File
mode: Mainline
branches:
master:
regex: master
increment: Patch
assembly-informational-format: '{MajorMinorPatch}+Branch.{BranchName}{PreReleaseTag}'
major-version-bump-message: '\+semver:\s?(breaking|major)'
minor-version-bump-message: '\+semver:\s?(feature|minor)'
patch-version-bump-message: '\+semver:\s?(fix|patch)'
commit-message-incrementing: Enabled
tag-prefix: '[vV]'
ignore:
sha: []
YAML Pipeline
- task: gitversion/setup@0
displayName: gitversion/setup
inputs:
versionSpec: '5.10.3'
- task: gitversion/execute@0
displayName: gitversion/execute
inputs:
useConfigFile: true
configFilePath: GitVersion.yml
Upvotes: 10
Views: 10090
Reputation: 141
I found the solution. The pipeline settings UI has a Shallow fetch setting.
Upvotes: 14
Reputation: 528
I had the same problem in one of my repos. Out of the blue. I could not find any specific reason why it happened, but by investigating how GitVersion works, I came to the conclusion that the shallow fetch was the culprit. I solved it by telling the pipeline to always fetch everything. I put this in my pipeline template, so hopefully this will not happen anymore.
- steps:
- checkout: self
fetchDepth: 0
Upvotes: 26
Reputation: 51988
You mention "Increasing the checkout depth", which hints at using a "sparse checkout" or "shallow repository" option your CI job (is this correct ?)
The drawback of a shallow repository is : the repo your CI job is running on doesn't have the history of your repo.
If your job needs to find out how many commits the current branch is ahead of master
, it needs at least the part of history that links master
to your current branch.
The easiest way is to turn off the sparse/shallow option,
another way can be to explicitly "deepen" the history for your branch :
git fetch --deepen=100 origin master
git fetch --deepen=100 origin [active branch]
Upvotes: 1