Skip to content

[BUG]: GitVersion (in Azure Devops) calculating wrong version when building a tag #4015

Closed as not planned
@arnoschuring-miele

Description

@arnoschuring-miele

Prerequisites

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

GitVersion package

AzureDevops task

GitVersion version

5.12.0

Operating system

Linux

What are you seeing?

When building on a tag in Azure Devops, GitVersion is generating a new pre-release version rather than using the already-placed tag. This seems entirely similar to #2074 and #2456.

The current config is quite minimal:

commit-date-format: yyyyMMdd
mode: Mainline
tag-prefix: '[vV]_'

I cannot run this locally to get more info, because a) when I do a git checkout of the tag locally, it generates the correct version number, and b) it seems to completely ignore any -verbosity argument specified.

I suspect this line (from the log) is the problem:

Detected forward merge [..] ; rewinding mainline to previous commit

And that may be because we merged the same branch twice:

*   dc43f3b (HEAD, tag: v_0.1.2, origin/main, main)
|\
| * 9e67e70 (origin/feature/1648-snip-branch-name, feature/1648-snip-branch-name)
* | 0ec823e
|\|
| * 7648056
| * 0daea29
| * f31a425
| * f83209c
| * 1c3ef10

|/
* a102d74

What is expected?

GitVersion should generate a version number that matches exactly the already-placed tag v_0.1.2 (as it does locally)

Steps to Reproduce

I have not been able to reproduce this locally, even with the exact git checkout procedure that ADO is using:

git init
git remote add origin $devops_repo_url
git fetch origin --tags
git fetch origin +dc43f3be8e9f7d955998e0554fdfb4286bfbdfee
git checkout --progress --force dc43f3be8e9f7d955998e0554fdfb4286bfbdfee
../gitversion.exe -verbosity diagnostic -config ../deployment-automation/config/gitversion.yaml

RepositoryFixture Test

No response

Output log or link to your CI build (if appropriate).

/opt/hostedtoolcache/GitVersion.Tool/5.12.0/x64/dotnet-gitversion /home/vsts/work/1/s /output json /output buildserver /config /home/vsts/work/1/_automation/config/gitversion.yaml
INFO [04/30/24 8:03:23:92] Working directory: /home/vsts/work/1/s
INFO [04/30/24 8:03:23:95] Project root is: /home/vsts/work/1/s/
INFO [04/30/24 8:03:23:95] DotGit directory is: /home/vsts/work/1/s/.git
INFO [04/30/24 8:03:23:95] Branch from build environment: refs/tags/v_0.1.2
INFO [04/30/24 8:03:23:95] Begin: Normalizing git directory for branch 'refs/tags/v_0.1.2'
  INFO [04/30/24 8:03:23:98] One remote found (origin -> 'https://[email protected]/$org/$proj/_git/$repo').
  INFO [04/30/24 8:03:23:98] Skipping fetching, if GitVersion does not calculate your version as expected you might need to allow fetching or use dynamic repositories
  INFO [04/30/24 8:03:23:99] Creating local branch tags/v_0.1.2 pointing at dc43f3b
  INFO [04/30/24 8:03:24:02] Creating local branch from remote tracking 'refs/remotes/origin/feature/1648-snip-branch-name'.
  INFO [04/30/24 8:03:24:03] Creating local branch from remote tracking 'refs/remotes/origin/main'.
  INFO [04/30/24 8:03:24:03] HEAD points at branch 'refs/heads/tags/v_0.1.2'.
  INFO [04/30/24 8:03:24:04] End: Normalizing git directory for branch 'refs/tags/v_0.1.2' (Took: 85.69ms)
  INFO [04/30/24 8:03:24:05] Begin: Loading version variables from disk cache
    INFO [04/30/24 8:03:24:05] Cache file /home/vsts/work/1/s/.git/gitversion_cache/533DF5CDE0896219ADDB98A2ACCB99A576CC506E.yml not found.
  INFO [04/30/24 8:03:24:05] End: Loading version variables from disk cache (Took: 0.46ms)
  INFO [04/30/24 8:03:24:05] Using latest commit on specified branch
  INFO [04/30/24 8:03:24:17] Running against branch: tags/v_0.1.2 (dc43f3b Merged PR 5351: [snip PR message])
  INFO [04/30/24 8:03:24:17] Current commit is tagged with version 0.1.2, version calculation is for metadata only.
  INFO [04/30/24 8:03:24:18] 0 commits found between dc43f3b Merged PR 5351: [snip PR message] and dc43f3b Merged PR 5351: [snip PR message]
  INFO [04/30/24 8:03:24:18] Begin: Calculating base versions
    INFO [04/30/24 8:03:24:19] No branch configuration found for branch tags/v_0.1.2, falling back to default configuration
    INFO [04/30/24 8:03:24:19] Begin: Attempting to inherit branch configuration from parent branch
      INFO [04/30/24 8:03:24:19] HEAD is merge commit, this is likely a pull request using feature/1648-snip-branch-name as base
      INFO [04/30/24 8:03:24:20] Begin: Finding branch source of 'feature/1648-snip-branch-name'
        INFO [04/30/24 8:03:24:21] Begin: Finding merge base between 'feature/1648-snip-branch-name' and 'main'.
          INFO [04/30/24 8:03:24:22] Found merge base of 7648056 follow template variable renames
          INFO [04/30/24 8:03:24:22] Merge base was due to a forward merge, next merge base is a102d74 bundle init
          INFO [04/30/24 8:03:24:22] Merge base of feature/1648-snip-branch-name' and 'main is a102d74 bundle init
        INFO [04/30/24 8:03:24:22] End: Finding merge base between 'feature/1648-snip-branch-name' and 'main'. (Took: 10.27ms)
      INFO [04/30/24 8:03:24:22] End: Finding branch source of 'feature/1648-snip-branch-name' (Took: 21.60ms)
      INFO [04/30/24 8:03:24:23] Begin: Getting branches containing the commit 'a102d74'.
        INFO [04/30/24 8:03:24:23] Trying to find direct branches.
        INFO [04/30/24 8:03:24:23] No direct branches found, searching through all branches.
        INFO [04/30/24 8:03:24:23] Searching for commits reachable from 'main'.
        INFO [04/30/24 8:03:24:23] The branch 'main' has a matching commit.
      INFO [04/30/24 8:03:24:23] End: Getting branches containing the commit 'a102d74'. (Took: 1.66ms)
      INFO [04/30/24 8:03:24:23] Found possible parent branches: main
    INFO [04/30/24 8:03:24:23] End: Attempting to inherit branch configuration from parent branch (Took: 38.50ms)
    INFO [04/30/24 8:03:24:23] Fallback base version: 0.1.0 with commit count source a102d7409179ba5d4b5e3dd443e80f67dc5411f0
    INFO [04/30/24 8:03:24:28] Git tag 'v_0.1.2': 0.1.2 with commit count source dc43f3be8e9f7d955998e0554fdfb4286bfbdfee
    INFO [04/30/24 8:03:24:30] Found multiple base versions which will produce the same SemVer (0.1.2), taking oldest source for commit counting (Git tag 'v_0.1.2')
    INFO [04/30/24 8:03:24:30] Base version used: Git tag 'v_0.1.2': 0.1.2 with commit count source dc43f3be8e9f7d955998e0554fdfb4286bfbdfee
  INFO [04/30/24 8:03:24:30] End: Calculating base versions (Took: 116.91ms)
  INFO [04/30/24 8:03:24:30] 0 commits found between dc43f3b Merged PR 5351: [snip PR message] and dc43f3b Merged PR 5351: [snip PR message]
  INFO [04/30/24 8:03:24:30] Begin: Using mainline development mode to calculate current version
    INFO [04/30/24 8:03:24:30] '^master$|^main$' does not match 'feature/1648-snip-branch-name'.
    INFO [04/30/24 8:03:24:30] '^support[/-]' does not match 'feature/1648-snip-branch-name'.
    INFO [04/30/24 8:03:24:30] '^master$|^main$' matches 'main'.
    INFO [04/30/24 8:03:24:30] Found merge base dc43f3be8e9f7d955998e0554fdfb4286bfbdfee for 'main'.
    INFO [04/30/24 8:03:24:30] '^master$|^main$' does not match 'tags/v_0.1.2'.
    INFO [04/30/24 8:03:24:31] '^support[/-]' does not match 'tags/v_0.1.2'.
    INFO [04/30/24 8:03:24:31] '^master$|^main$' does not match 'feature/1648-snip-branch-name'.
    INFO [04/30/24 8:03:24:31] '^support[/-]' does not match 'feature/1648-snip-branch-name'.
    INFO [04/30/24 8:03:24:31] '^master$|^main$' matches 'main'.
    INFO [04/30/24 8:03:24:31] Found merge base dc43f3be8e9f7d955998e0554fdfb4286bfbdfee for 'origin/main'.
    INFO [04/30/24 8:03:24:31] Found possible mainline branches: main, origin/main
    INFO [04/30/24 8:03:24:31] Multiple mainlines (main, origin/main) have the same merge base for the current branch, choosing main because we found that branch first...
    INFO [04/30/24 8:03:24:31] Detected forward merge at dc43f3b Merged PR 5351: [snip PR message]; rewinding mainline to previous commit 0ec823e Merged PR [snip PR message]
    INFO [04/30/24 8:03:24:31] Current branch (tags/v_0.1.2) was branch from 0ec823e Merged PR 5349: [snip PR message]
    INFO [04/30/24 8:03:24:31] 2 commits found between 0ec823e Merged PR 5349: [snip PR message] and dc43f3b Merged PR 5351: [snip PR message]
    INFO [04/30/24 8:03:24:32] Performing Patch increment for current branch 
  INFO [04/30/24 8:03:24:32] End: Using mainline development mode to calculate current version (Took: 21.16ms)
  INFO [04/30/24 8:03:24:32] Using branch name to calculate version tag
  INFO [04/30/24 8:03:24:32] Begin: Getting version tags from branch 'refs/heads/tags/v_0.1.2'.
  INFO [04/30/24 8:03:24:33] End: Getting version tags from branch 'refs/heads/tags/v_0.1.2'. (Took: 4.22ms)
  INFO [04/30/24 8:03:24:33] Begin: Creating dictionary
  INFO [04/30/24 8:03:24:34] End: Creating dictionary (Took: 3.97ms)
  INFO [04/30/24 8:03:24:34] Begin: Storing version variables to cache file /home/vsts/work/1/s/.git/gitversion_cache/533DF5CDE0896219ADDB98A2ACCB99A576CC506E.yml
  INFO [04/30/24 8:03:24:37] End: Storing version variables to cache file /home/vsts/work/1/s/.git/gitversion_cache/533DF5CDE0896219ADDB98A2ACCB99A576CC506E.yml (Took: 27.00ms)
Executing GenerateSetVersionMessage for 'AzurePipelines'.
Executing GenerateBuildLogOutput for 'AzurePipelines'.

{
  "Major": 0,
  "Minor": 1,
  "Patch": 3,
  "PreReleaseTag": "tags-v-0-1-2.2",
  "PreReleaseTagWithDash": "-tags-v-0-1-2.2",
  "PreReleaseLabel": "tags-v-0-1-2",
  "PreReleaseLabelWithDash": "-tags-v-0-1-2",
  "PreReleaseNumber": 2,
  "WeightedPreReleaseNumber": 2,
  "BuildMetaData": null,
  "BuildMetaDataPadded": "",
  "FullBuildMetaData": "Branch.tags-v-0.1.2.Sha.dc43f3be8e9f7d955998e0554fdfb4286bfbdfee",
  "MajorMinorPatch": "0.1.3",
  "SemVer": "0.1.3-tags-v-0-1-2.2",
  "LegacySemVer": "0.1.3-tags-v-0-1-2-2",
  "LegacySemVerPadded": "0.1.3-tags-v-0-1-2-0002",
  "AssemblySemVer": "0.1.3.0",
  "AssemblySemFileVer": "0.1.3.0",
  "FullSemVer": "0.1.3-tags-v-0-1-2.2",
  "InformationalVersion": "0.1.3-tags-v-0-1-2.2+Branch.tags-v-0.1.2.Sha.dc43f3be8e9f7d955998e0554fdfb4286bfbdfee",
  "BranchName": "tags/v_0.1.2",
  "EscapedBranchName": "tags-v-0-1-2",
  "Sha": "dc43f3be8e9f7d955998e0554fdfb4286bfbdfee",
  "ShortSha": "dc43f3b",
  "NuGetVersionV2": "0.1.3-tags-v-0-1-2-0002",
  "NuGetVersion": "0.1.3-tags-v-0-1-2-0002",
  "NuGetPreReleaseTagV2": "tags-v-0-1-2-0002",
  "NuGetPreReleaseTag": "tags-v-0-1-2-0002",
  "VersionSourceSha": "0ec823e29ec9a35f811fc305220c3c212c56226e",
  "CommitsSinceVersionSource": 2,
  "CommitsSinceVersionSourcePadded": "0002",
  "UncommittedChanges": 0,
  "CommitDate": "20240426"
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions