GitTools / GitVersion

From git log to SemVer in no time
https://gitversion.net/docs/
MIT License
2.87k stars 654 forks source link

[ISSUE]: Version skipping tag from main branch #4214

Closed markcandelora closed 1 month ago

markcandelora commented 1 month ago

Prerequisites

GitVersion package

GitVersion.Tool

GitVersion version

6.0.2

Operating system

Windows

What are you seeing?

GitVersion seems to be ignoring the most recent tag on main and performing the calculation from an old tag.

The command below shows the version being returned is v2.0.8, but based on the log I'd expect to see v2.1.1

> dotnet-gitversion -diag
INFO [24-09-18 21:50:26:86] Please run `git log --graph --format="%h %cr %d" --decorate --date=relative --all --remotes=*` to see the git graph. This can help you troubleshoot any issues.

INFO [24-09-18 21:50:26:86] Working directory: C:\git\project
INFO [24-09-18 21:50:26:91] Project root is: C:\git\project\
INFO [24-09-18 21:50:26:92] DotGit directory is: C:\git\project\.git
INFO [24-09-18 21:50:26:92] Branch from build environment:
INFO [24-09-18 21:50:26:92] Found configuration file at 'C:\git\project\GitVersion.yml'
INFO [24-09-18 21:50:27:34] Using latest commit on specified branch
INFO [24-09-18 21:50:27:39] Getting tagged semantic versions. TagPrefix: [vV] and Format: Strict
INFO [24-09-18 21:50:28:26] Running against branch: main ('2cf66dd' - Upgrade to .net 8 & rev all dependent packages (#136))
INFO [24-09-18 21:50:28:27] -< Begin: Fetching the base versions for version calculation... >-
  INFO [24-09-18 21:50:28:27] Calculating base versions for 'main'
  INFO [24-09-18 21:50:28:27] -< Begin: [Using 'ConfiguredNextVersionVersionStrategy' strategy] >-
  INFO [24-09-18 21:50:28:28] -< End: [Using 'ConfiguredNextVersionVersionStrategy' strategy] (Took: 1.15ms) >-
  INFO [24-09-18 21:50:28:28] -< Begin: [Using 'MainlineVersionStrategy' strategy] >-
    INFO [24-09-18 21:50:28:28] -< Begin: Getting tagged semantic versions on branch 'refs/heads/main'. TagPrefix: [vV] and Format: Strict >-
    INFO [24-09-18 21:50:28:29] -< End: Getting tagged semantic versions on branch 'refs/heads/main'. TagPrefix: [vV] and Format: Strict (Took: 3.87ms) >-
    INFO [24-09-18 21:50:28:33] -< Begin: Finding branches source of 'main' >-
    INFO [24-09-18 21:50:28:36] -< End: Finding branches source of 'main' (Took: 36.02ms) >-
    INFO [24-09-18 21:50:28:39] CommitOnTrunk: Force version increment '2.0.7-1' +semver 'Patch' with label '' based on commit '347d59e'.
  INFO [24-09-18 21:50:28:39] -< End: [Using 'MainlineVersionStrategy' strategy] (Took: 117.50ms) >-
  INFO [24-09-18 21:50:28:39] -< Begin: [Using 'MergeMessageVersionStrategy' strategy] >-
  INFO [24-09-18 21:50:28:40] -< End: [Using 'MergeMessageVersionStrategy' strategy] (Took: 1.47ms) >-
  INFO [24-09-18 21:50:28:40] -< Begin: [Using 'TaggedCommitVersionStrategy' strategy] >-
  INFO [24-09-18 21:50:28:40] -< End: [Using 'TaggedCommitVersionStrategy' strategy] (Took: 1.02ms) >-
  INFO [24-09-18 21:50:28:40] -< Begin: [Using 'TrackReleaseBranchesVersionStrategy' strategy] >-
  INFO [24-09-18 21:50:28:40] -< End: [Using 'TrackReleaseBranchesVersionStrategy' strategy] (Took: 0.82ms) >-
  INFO [24-09-18 21:50:28:40] -< Begin: [Using 'VersionInBranchNameVersionStrategy' strategy] >-
  INFO [24-09-18 21:50:28:40] -< End: [Using 'VersionInBranchNameVersionStrategy' strategy] (Took: 0.82ms) >-
INFO [24-09-18 21:50:28:40] -< End: Fetching the base versions for version calculation... (Took: 131.91ms) >-
INFO [24-09-18 21:50:28:40] -------------------------------------------------------
INFO [24-09-18 21:50:28:40] Base version used: CommitOnTrunk: Take '2.0.7-1' based on commit '347d59e'.
INFO [24-09-18 21:50:28:40] -------------------------------------------------------
INFO [24-09-18 21:50:28:40] -< Begin: Using continuous deployment workflow to calculate the incremented version. >-
  INFO [24-09-18 21:50:28:41] 1 commits found between '347d59e' - Separate sample generation into individual scripts (resolves #133) and '2cf66dd' - Upgrade to .net 8 & rev all dependent packages (#136)
INFO [24-09-18 21:50:28:41] -< End: Using continuous deployment workflow to calculate the incremented version. (Took: 4.19ms) >-
INFO [24-09-18 21:50:28:41] Found configuration file at 'C:\git\project\GitVersion.yml'
Executing GenerateSetVersionMessage for 'LocalBuild'.

Executing GenerateBuildLogOutput for 'LocalBuild'.
{
  "AssemblySemFileVer": "2.0.8.0",
  "AssemblySemVer": "2.0.8.0",
  "BranchName": "main",
  "BuildMetaData": null,
  "CommitDate": "2024-09-17",
  "CommitsSinceVersionSource": 1,
  "EscapedBranchName": "main",
  "FullBuildMetaData": "Branch.main.Sha.2cf66dd43029ba7b4450fb078fc78a6c3c07b16f",
  "FullSemVer": "2.0.8",
  "InformationalVersion": "2.0.8+Branch.main.Sha.2cf66dd43029ba7b4450fb078fc78a6c3c07b16f",
  "Major": 2,
  "MajorMinorPatch": "2.0.8",
  "Minor": 0,
  "Patch": 8,
  "PreReleaseLabel": "",
  "PreReleaseLabelWithDash": "",
  "PreReleaseNumber": null,
  "PreReleaseTag": "",
  "PreReleaseTagWithDash": "",
  "SemVer": "2.0.8",
  "Sha": "2cf66dd43029ba7b4450fb078fc78a6c3c07b16f",
  "ShortSha": "2cf66dd",
  "UncommittedChanges": 3,
  "VersionSourceSha": "347d59eb5600e041dffcecd5444eb30a706b9d8c",
  "WeightedPreReleaseNumber": 60000
}
> git log --graph --format="%h %cr %d" --decorate --date=relative --all --remotes=*
*   8e2704d 3 hours ago  (refs/stash)
|\
| * 43f75d8 3 hours ago
|/
* 2cf66dd 29 hours ago  (HEAD -> main, tag: v2.1, origin/main, origin/HEAD, mac/141-versioning-not-incrementing-properly)
| * 9b519e2 35 hours ago  (origin/markcandelora-readme-update)
| *   f01777d 35 hours ago  (markcandelora-readme-update)
| |\
| | * 8adaa81 2 days ago
| * | 9344e4a 35 hours ago
| |/
| * 6bc2984 2 days ago 
| * aa97334 2 days ago
| *   6306b43 2 days ago
| |\
| | * 4df2b1f 2 days ago
| * | f31332c 2 days ago
| * | 1edce84 2 days ago
| |/
| * 6e60031 2 days ago
| * cac27dd 2 days ago
| * 20a84e6 2 days ago
| * f854b41 6 days ago
| * c6f5a73 7 days ago
| * 14f04c5 7 days ago 
| * 47c1291 7 days ago
| * d28ca1e 7 days ago
| * bdabcea 7 days ago
| * 1296b2f 7 days ago
|/
* 347d59e 1 year, 3 months ago
* b748394 1 year, 3 months ago
* 9ed98da 1 year, 3 months ago
* fc7510f 1 year, 3 months ago
* 7f2a52c 1 year, 3 months ago
* 5a5a3c2 1 year, 3 months ago
* ccfc352 1 year, 4 months ago
* 105d44a 1 year, 4 months ago  (tag: v2.0)
> dotnet-gitversion -showconfig   
workflow: TrunkBased/preview1
assembly-versioning-scheme: MajorMinorPatch
assembly-file-versioning-scheme: MajorMinorPatch
tag-prefix: '[vV]'
version-in-branch-pattern: (?<version>[vV]?\d+(\.\d+)?(\.\d+)?).*
major-version-bump-message: '\+semver:\s?(breaking|major)'
minor-version-bump-message: '\+semver:\s?(feature|minor)'
patch-version-bump-message: '\+semver:\s?(fix|patch)'
no-bump-message: '\+semver:\s?(none|skip)'
tag-pre-release-weight: 60000
commit-date-format: yyyy-MM-dd
merge-message-formats: {}
update-build-number: true
semantic-version-format: Strict
strategies:
- ConfiguredNextVersion
- Mainline
branches:
  main:
    mode: ContinuousDeployment
    label: ''
    increment: Patch
    prevent-increment:
      of-merged-branch: true
    track-merge-target: false
    track-merge-message: true
    regex: ^master$|^main$
    source-branches: []
    is-source-branch-for: []
    tracks-release-branches: false
    is-release-branch: false
    is-main-branch: true
    pre-release-weight: 55000
  feature:
    mode: ContinuousDelivery
    label: '{BranchName}'
    increment: Minor
    prevent-increment:
      when-current-commit-tagged: false
    track-merge-message: true
    regex: ^features?[/-](?<BranchName>.+)
    source-branches:
    - main
    is-source-branch-for: []
    is-main-branch: false
    pre-release-weight: 30000
  hotfix:
    mode: ContinuousDelivery
    label: '{BranchName}'
    increment: Patch
    prevent-increment:
      when-current-commit-tagged: false
    regex: ^hotfix(es)?[/-](?<BranchName>.+)
    source-branches:
    - main
    is-source-branch-for: []
    is-release-branch: true
    is-main-branch: false
    pre-release-weight: 30000
  pull-request:
    mode: ContinuousDelivery
    label: PullRequest
    increment: Inherit
    prevent-increment:
      of-merged-branch: true
      when-current-commit-tagged: false
    label-number-pattern: '[/-](?<number>\d+)'
    track-merge-message: true
    regex: ^(pull|pull\-requests|pr)[/-]
    source-branches:
    - main
    - feature
    - hotfix
    is-source-branch-for: []
    pre-release-weight: 30000
  unknown:
    increment: Patch
    prevent-increment:
      when-current-commit-tagged: false
    regex: (?<BranchName>.+)
    source-branches:
    - main
    is-source-branch-for: []
    pre-release-weight: 30000
ignore:
  sha: []
mode: ContinuousDelivery
label: '{BranchName}'
increment: Inherit
prevent-increment:
  of-merged-branch: false
  when-branch-merged: false
  when-current-commit-tagged: true
track-merge-target: false
track-merge-message: true
commit-message-incrementing: Enabled
regex: ''
source-branches: []
is-source-branch-for: []
tracks-release-branches: false
is-release-branch: false
is-main-branch: false

What is expected?

v2.1.1

Steps to Reproduce

  1. start a project with GitVersion v5.12
  2. tag a commit with v2.0 --> result is v2.0.0
  3. perform 7 additional commits --> results v2.0.1 - v2.0.7
  4. wait a year
  5. perform a new commit with tag v2.1 --> result is v2.1.0
  6. upgrade GitVersion to v6.0.2
  7. perform a new commit --> result is v2.0.8

RepositoryFixture Test

No response

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

No response