Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] GitVersion increments version on tagged detached HEAD when coming from release branch #2478

Closed
chrbkr opened this issue Dec 14, 2020 · 5 comments
Labels
Milestone

Comments

@chrbkr
Copy link

chrbkr commented Dec 14, 2020

When checking out a tag, I want to be able to build the exact same version.

This is working if the commit in master is a merge from hotfix/MyHotfixBranch.

However, if the commit is a merge from e.g. release/3.3.2, the version is incremented. I tried this with several tags, and it seems consistent.

Is this a bug or is there something wrong with my config?

Unwanted Version Increment:

>git checkout 3.3.0
HEAD is now at afb9fd592 Merge branch 'release/3.3.0'

>git status
HEAD detached at 3.3.0
nothing to commit, working tree clean

>GitVersion
{
  "Major":3,
  "Minor":3,
  "Patch":1,
  "PreReleaseTag":"-no-branch-.1",
  "PreReleaseTagWithDash":"--no-branch-.1",
  "PreReleaseLabel":"-no-branch-",
  "PreReleaseNumber":1,
  "WeightedPreReleaseNumber":1,
  "BuildMetaData":209,
  "BuildMetaDataPadded":"0209",
  "FullBuildMetaData":"209.Branch.-no-branch-.Sha.afb9fd5924acbd6cb7d411446a7d9d7a3efa3807",
  "MajorMinorPatch":"3.3.1",
  "SemVer":"3.3.1--no-branch-.1",
  "LegacySemVer":"3.3.1--no-branch-1",
  "LegacySemVerPadded":"3.3.1--no-branch-0001",
  "AssemblySemVer":"3.3.1.1",
  "AssemblySemFileVer":"3.3.1.1",
  "FullSemVer":"3.3.1--no-branch-.1+209",
  "InformationalVersion":"3.3.1--no-branch-.1+209",
  "BranchName":"(no branch)",
  "EscapedBranchName":"-no-branch-",
  "Sha":"afb9fd5924acbd6cb7d411446a7d9d7a3efa3807",
  "ShortSha":"afb9fd5",
  "NuGetVersionV2":"3.3.1--no-branch-0001",
  "NuGetVersion":"3.3.1--no-branch-0001",
  "NuGetPreReleaseTagV2":"-no-branch-0001",
  "NuGetPreReleaseTag":"-no-branch-0001",
  "VersionSourceSha":"3242e745baa1789364be2f1878112fcb1b4568db",
  "CommitsSinceVersionSource":209,
  "CommitsSinceVersionSourcePadded":"0209",
  "UncommittedChanges":0,
  "CommitDate":"2020-10-26"
}

Working:

>git checkout 3.3.5
HEAD is now at b84e8f28d Merge branch 'hotfix/SomeHotfix'

>git status
HEAD detached at 3.3.5
nothing to commit, working tree clean

>GitVersion
{
  "Major":3,
  "Minor":3,
  "Patch":5,
  "PreReleaseTag":"",
  "PreReleaseTagWithDash":"",
  "PreReleaseLabel":"",
  "PreReleaseNumber":"",
  "WeightedPreReleaseNumber":60000,
  "BuildMetaData":"",
  "BuildMetaDataPadded":"",
  "FullBuildMetaData":"Branch.-no-branch-.Sha.b84e8f28de192a7979afe010ad1693d882233b83",
  "MajorMinorPatch":"3.3.5",
  "SemVer":"3.3.5",
  "LegacySemVer":"3.3.5",
  "LegacySemVerPadded":"3.3.5",
  "AssemblySemVer":"3.3.5.60000",
  "AssemblySemFileVer":"3.3.5.60000",
  "FullSemVer":"3.3.5",
  "InformationalVersion":"3.3.5",
  "BranchName":"(no branch)",
  "EscapedBranchName":"-no-branch-",
  "Sha":"b84e8f28de192a7979afe010ad1693d882233b83",
  "ShortSha":"b84e8f2",
  "NuGetVersionV2":"3.3.5",
  "NuGetVersion":"3.3.5",
  "NuGetPreReleaseTagV2":"",
  "NuGetPreReleaseTag":"",
  "VersionSourceSha":"b84e8f28de192a7979afe010ad1693d882233b83",
  "CommitsSinceVersionSource":48,
  "CommitsSinceVersionSourcePadded":"0048",
  "UncommittedChanges":0,
  "CommitDate":"2020-11-12"
}

Config:

assembly-versioning-scheme: MajorMinorPatch
assembly-versioning-format: '{MajorMinorPatch}.{WeightedPreReleaseNumber}'
assembly-file-versioning-format: '{MajorMinorPatch}.{WeightedPreReleaseNumber}'
assembly-informational-format: '{FullSemVer}'
branches:
  master:
    regex: master
    mode: ContinuousDelivery
    tag: ''
    increment: Patch
    prevent-increment-of-merged-branch-version: true
    track-merge-target: false
    tracks-release-branches: false
    is-release-branch: false
  release:
    regex: release(s)?[/-]
    mode: ContinuousDeployment
    tag: beta
    increment: Patch
    prevent-increment-of-merged-branch-version: true
    track-merge-target: false
    tracks-release-branches: false
    is-release-branch: true
  feature:
    regex: feature(s)?[/-]
    mode: ContinuousDeployment
    tag: useBranchName
    increment: Inherit
    prevent-increment-of-merged-branch-version: false
    track-merge-target: false
    tracks-release-branches: false
    is-release-branch: false
  pull-request:
    regex: (pull|pull\-requests|pr)[/-]
    mode: ContinuousDelivery
    tag: PullRequest
    increment: Inherit
    prevent-increment-of-merged-branch-version: false
    tag-number-pattern: '[/-](?<number>\d+)[-/]'
    track-merge-target: false
    tracks-release-branches: false
    is-release-branch: false
  hotfix:
    regex: hotfix(es)?[/-]
    mode: ContinuousDeployment
    tag: beta
    increment: Patch
    prevent-increment-of-merged-branch-version: false
    track-merge-target: false
    tracks-release-branches: false
    is-release-branch: false
  support:
    regex: support[/-]
    mode: ContinuousDelivery
    tag: ''
    increment: Patch
    prevent-increment-of-merged-branch-version: true
    track-merge-target: false
    tracks-release-branches: false
    is-release-branch: false
  develop:
    regex: dev(elop)?(ment)?$
    mode: ContinuousDeployment
    tag: unstable
    increment: Inherit
    prevent-increment-of-merged-branch-version: false
    track-merge-target: true
    tracks-release-branches: true
    is-release-branch: false
ignore:
  sha: []
@chrbkr chrbkr added the bug label Dec 14, 2020
@asbjornu
Copy link
Member

Seems like a duplicate of #2456.

@atti92
Copy link

atti92 commented Aug 16, 2021

We have the same issue with 5.6.11

INFO [08/16/21 13:39:28:47] No branch configuration found for branch tags/v1.5.0, falling back to default configuration
INFO [08/16/21 13:39:28:47] Begin: Attempting to inherit branch configuration from parent branch
INFO [08/16/21 13:39:28:48] HEAD is merge commit, this is likely a pull request using tags/v1.5.0 as base
INFO [08/16/21 13:39:28:50] Begin: Finding branch source of 'tags/v1.5.0'
INFO [08/16/21 13:39:28:50] Begin: Finding merge base between 'tags/v1.5.0' and 'develop'.

Then we get:
1.5.1-tags-v1-5-0

@asbjornu
Copy link
Member

This should have been fixed in #2577. Ideas about why it's resurfacing, @gep13?

@asbjornu
Copy link
Member

Fixed by #3338.

@asbjornu asbjornu added this to the 5.x milestone Jan 20, 2023
@arturcic arturcic modified the milestones: 5.x, 5.12.0 Jan 20, 2023
@arturcic
Copy link
Member

🎉 This issue has been resolved in version 5.12.0 🎉
The release is available on:

Your GitReleaseManager bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants