Skip to content

Hotfix branch doesn't increment version #2850

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

Closed
ramondeklein opened this issue Sep 16, 2021 · 2 comments
Closed

Hotfix branch doesn't increment version #2850

ramondeklein opened this issue Sep 16, 2021 · 2 comments
Labels

Comments

@ramondeklein
Copy link

It seems that a hotfix doesn't increment the patch number. I have created an example repository. When you checkout the master branch, then it should have version 0.1.1, but it gets 0.1.0 instead.

These are the actual commits (in the flow from the head to the base):

$ git log --pretty=oneline --abbrev-commit
e362bb4 (HEAD -> master) Merge branch 'hotfix/0.1.1'
038ecc7 (origin/hotfix/0.1.1, hotfix/0.1.1) Commit 11
2accc04 Commit 10
cf06c17 Merge branch 'release/0.1'
b450aee (origin/release/0.1, release/0.1) Commit 7
d87a33b Commit 4
8a6b048 Commit 3
3ed8392 Commit 2
a05cc26 Commit 1
8ac16e1 Initial commit

When I run GitVersion, then I get the following output:

{
  "Major": 0,
  "Minor": 1,
  "Patch": 0,
  "PreReleaseTag": "",
  "PreReleaseTagWithDash": "",
  "PreReleaseLabel": "",
  "PreReleaseLabelWithDash": "",
  "PreReleaseNumber": null,
  "WeightedPreReleaseNumber": 60000,
  "BuildMetaData": 9,
  "BuildMetaDataPadded": "0009",
  "FullBuildMetaData": "9.Branch.master.Sha.e362bb4e1f9819aefb9e9a38f4e99f865e138a10",
  "MajorMinorPatch": "0.1.0",
  "SemVer": "0.1.0",
  "LegacySemVer": "0.1.0",
  "LegacySemVerPadded": "0.1.0",
  "AssemblySemVer": "0.1.0.0",
  "AssemblySemFileVer": "0.1.0.0",
  "FullSemVer": "0.1.0+9",
  "InformationalVersion": "0.1.0+9.Branch.master.Sha.e362bb4e1f9819aefb9e9a38f4e99f865e138a10",
  "BranchName": "master",
  "EscapedBranchName": "master",
  "Sha": "e362bb4e1f9819aefb9e9a38f4e99f865e138a10",
  "ShortSha": "e362bb4",
  "NuGetVersionV2": "0.1.0",
  "NuGetVersion": "0.1.0",
  "NuGetPreReleaseTagV2": "",
  "NuGetPreReleaseTag": "",
  "VersionSourceSha": "8ac16e14fe116f94481be06b0ae1a7b4e8a279f9",
  "CommitsSinceVersionSource": 9,
  "CommitsSinceVersionSourcePadded": "0009",
  "UncommittedChanges": 1,
  "CommitDate": "2021-09-16"
}

And the logging shows:

$ gitversion /output buildserver /nocache
INFO [09/16/21 17:42:54:87] Working directory: C:\Users\Ramon\Documents\OpenSource\GitVersion-issue
INFO [09/16/21 17:42:54:89] Project root is: C:\Users\Ramon\Documents\OpenSource\GitVersion-issue\
INFO [09/16/21 17:42:54:89] DotGit directory is: C:\Users\Ramon\Documents\OpenSource\GitVersion-issue\.git
INFO [09/16/21 17:42:54:97] Using latest commit on specified branch
INFO [09/16/21 17:42:54:99] Running against branch: master (e362bb4 Merge branch 'hotfix/0.1.1')
INFO [09/16/21 17:42:54:99] Begin: Calculating base versions
  INFO [09/16/21 17:42:55:00] Fallback base version: 0.1.0 with commit count source 8ac16e14fe116f94481be06b0ae1a7b4e8a279f9
  INFO [09/16/21 17:42:55:01] Found commit [e362bb4 Merge branch 'hotfix/0.1.1'] matching merge message format: Default
  INFO [09/16/21 17:42:55:01] Merge message 'Merge branch 'release/0.1'': 0.1.0 with commit count source cf06c1772568d7109a47b619874c7f94644e36e3
  INFO [09/16/21 17:42:55:03] Found multiple base versions which will produce the same SemVer (0.1.0), taking oldest source for commit counting (Fallback base version)
  INFO [09/16/21 17:42:55:03] Base version used: Fallback base version: 0.1.0 with commit count source 8ac16e14fe116f94481be06b0ae1a7b4e8a279f9
  INFO [09/16/21 17:42:55:03] End: Calculating base versions (Took: 43.88ms)
  INFO [09/16/21 17:42:55:04] 9 commits found between 8ac16e1 Initial commit and e362bb4 Merge branch 'hotfix/0.1.1'
  INFO [09/16/21 17:42:55:04] Skipping version increment
  INFO [09/16/21 17:42:55:04] 9 commits found between 8ac16e1 Initial commit and e362bb4 Merge branch 'hotfix/0.1.1'
  INFO [09/16/21 17:42:55:05] Done writing

The merge message from the hotfix-branch isn't picked up by GitVersion. It does show the merge-message of the release branch, so I added the following GitVersion.yml file to test if that helps:

branches:
  hotfix:
    is-release-branch: true

Now, the correct version is generated:

{
  "Major": 0,
  "Minor": 1,
  "Patch": 1,
  "PreReleaseTag": "",
  "PreReleaseTagWithDash": "",
  "PreReleaseLabel": "",
  "PreReleaseLabelWithDash": "",
  "PreReleaseNumber": null,
  "WeightedPreReleaseNumber": 60000,
  "BuildMetaData": 0,
  "BuildMetaDataPadded": "0000",
  "FullBuildMetaData": "0.Branch.master.Sha.e362bb4e1f9819aefb9e9a38f4e99f865e138a10",
  "MajorMinorPatch": "0.1.1",
  "SemVer": "0.1.1",
  "LegacySemVer": "0.1.1",
  "LegacySemVerPadded": "0.1.1",
  "AssemblySemVer": "0.1.1.0",
  "AssemblySemFileVer": "0.1.1.0",
  "FullSemVer": "0.1.1+0",
  "InformationalVersion": "0.1.1+0.Branch.master.Sha.e362bb4e1f9819aefb9e9a38f4e99f865e138a10",
  "BranchName": "master",
  "EscapedBranchName": "master",
  "Sha": "e362bb4e1f9819aefb9e9a38f4e99f865e138a10",
  "ShortSha": "e362bb4",
  "NuGetVersionV2": "0.1.1",
  "NuGetVersion": "0.1.1",
  "NuGetPreReleaseTagV2": "",
  "NuGetPreReleaseTag": "",
  "VersionSourceSha": "e362bb4e1f9819aefb9e9a38f4e99f865e138a10",
  "CommitsSinceVersionSource": 0,
  "CommitsSinceVersionSourcePadded": "0000",
  "UncommittedChanges": 1,
  "CommitDate": "2021-09-16"
}

And the logging shows:

$ gitversion /output buildserver /nocache
INFO [09/16/21 17:45:50:31] Working directory: C:\Users\Ramon\Documents\OpenSource\GitVersion-issue
INFO [09/16/21 17:45:50:33] Project root is: C:\Users\Ramon\Documents\OpenSource\GitVersion-issue\
INFO [09/16/21 17:45:50:33] DotGit directory is: C:\Users\Ramon\Documents\OpenSource\GitVersion-issue\.git
INFO [09/16/21 17:45:50:40] Using latest commit on specified branch
INFO [09/16/21 17:45:50:42] Running against branch: master (e362bb4 Merge branch 'hotfix/0.1.1')
INFO [09/16/21 17:45:50:42] Begin: Calculating base versions
  INFO [09/16/21 17:45:50:43] Fallback base version: 0.1.0 with commit count source 8ac16e14fe116f94481be06b0ae1a7b4e8a279f9
  INFO [09/16/21 17:45:50:45] Found commit [e362bb4 Merge branch 'hotfix/0.1.1'] matching merge message format: Default
  INFO [09/16/21 17:45:50:45] Found commit [e362bb4 Merge branch 'hotfix/0.1.1'] matching merge message format: Default
  INFO [09/16/21 17:45:50:45] Merge message 'Merge branch 'hotfix/0.1.1'': 0.1.1 with commit count source e362bb4e1f9819aefb9e9a38f4e99f865e138a10
  INFO [09/16/21 17:45:50:45] Merge message 'Merge branch 'release/0.1'': 0.1.0 with commit count source cf06c1772568d7109a47b619874c7f94644e36e3
  INFO [09/16/21 17:45:50:47] Found multiple base versions which will produce the same SemVer (0.1.1), taking oldest source for commit counting (Merge message 'Merge branch 'hotfix/0.1.1'')
  INFO [09/16/21 17:45:50:47] Base version used: Merge message 'Merge branch 'hotfix/0.1.1'': 0.1.1 with commit count source e362bb4e1f9819aefb9e9a38f4e99f865e138a10
  INFO [09/16/21 17:45:50:47] End: Calculating base versions (Took: 44.61ms)
  INFO [09/16/21 17:45:50:47] 0 commits found between e362bb4 Merge branch 'hotfix/0.1.1' and e362bb4 Merge branch 'hotfix/0.1.1'
  INFO [09/16/21 17:45:50:47] Skipping version increment
  INFO [09/16/21 17:45:50:47] 0 commits found between e362bb4 Merge branch 'hotfix/0.1.1' and e362bb4 Merge branch 'hotfix/0.1.1'
  INFO [09/16/21 17:45:50:48] Done writing

Setting a hotfix to a release-branch seems completely wrong. What's going on here?

@ramondeklein
Copy link
Author

Might be a duplicate of #2336.

@asbjornu
Copy link
Member

asbjornu commented Mar 8, 2022

I believe this is a duplicate of #2336, yes. Closing.

@asbjornu asbjornu closed this as completed Mar 8, 2022
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

2 participants