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] Minor version increased instead of the prerelease tag #3137

Closed
mmisztal1980 opened this issue Jun 4, 2022 · 8 comments
Closed

[Bug] Minor version increased instead of the prerelease tag #3137

mmisztal1980 opened this issue Jun 4, 2022 · 8 comments
Labels
Milestone

Comments

@mmisztal1980
Copy link

mmisztal1980 commented Jun 4, 2022

Describe the bug
A clear and concise description of what the bug is.

Expected Behavior

I'm expecting the minor version to stay the same as the one dictated by the parent release/* branch. I'm not sure if this is due to using the minor-version-bump-message, however I was under the impression that the release/* branch behavior should override that?

Actual Behavior

dotnet giversion /diag yields:

INFO [06/04/22 12:26:27:72] Dumping commit graph: 
INFO [06/04/22 12:26:28:32] * b4f4fea 13 days ago  (HEAD -> release/0.28)
* f79612b 13 days ago 
| * 22c36c1 2 weeks ago  (origin/release/0.28)
|/  
* d47d236 2 weeks ago  (origin/main, origin/HEAD, main)
* 14573d5 2 weeks ago 
* 653763c 2 weeks ago 
* 097d849 2 weeks ago 
*   28c02b5 2 weeks ago  (tag: 0.27)
|\  
| * 625926b 2 weeks ago  (origin/release/0.27, release/0.27)
|/  
* 963957f 2 weeks ago 
* cd3536f 2 weeks ago 
* a35bcae 2 weeks ago 
* b232317 3 weeks ago 
* 56f6c01 3 weeks ago 
*   255539c 3 weeks ago  (tag: 0.25)
|\  
| * eb8f7a9 3 weeks ago  (origin/release/0.25, release/0.25)
|/  
* 5da4c5b 3 weeks ago 
* c65cd24 3 weeks ago 
*   962d148 3 weeks ago  (tag: 0.24)
|\  
| * 255b09b 3 weeks ago  (origin/release/0.24, release/0.24)
|/  
*   fdd3259 3 weeks ago 
|\  
| *   32f1124 3 weeks ago  (tag: 0.23)
| |\  
| | * b930a9c 3 weeks ago  (origin/release/0.23, release/0.23)
| |/  
* / 36ba6e3 3 weeks ago 
|/  
* 06c6671 3 weeks ago 
*   7abb068 3 weeks ago  (tag: 0.22)
|\  
| * a90cc99 3 weeks ago  (origin/release/0.22, release/0.22)
|/  
* dcead44 3 weeks ago 
*   00520c4 3 weeks ago  (tag: 0.21)
|\  
| * c7d5390 3 weeks ago  (origin/release/0.21, release/0.21)
|/  
*   6b5ac9a 3 weeks ago 
|\  
| * 2089ae4 3 weeks ago  (origin/release/0.20, release/0.20)
|/  
*   729bb88 3 weeks ago 
|\  
| *   c9fbe97 3 weeks ago 
| |\  
| | * 27ec5d0 3 weeks ago  (origin/release/0.17, release/0.17)
| |/  
* / b589548 3 weeks ago 
|/  
* 821e221 3 weeks ago 
*   eea9f14 3 weeks ago 
|\  
| * f78bcb0 3 weeks ago  (origin/release/0.16, release/0.16)
|/  
*   8bbef85 3 weeks ago 
|\  
| * 42bc972 3 weeks ago  (origin/release/0.15, release/0.15)
|/  
*   53e85f5 3 weeks ago 
|\  
| * 146bd21 3 weeks ago  (origin/release/0.14, release/0.14)
| * 2a072cb 3 weeks ago 
| * a962164 3 weeks ago 
|/  
* e5678d5 3 weeks ago 
* 18fc587 3 weeks ago 
* 7d162ee 3 weeks ago 
* 3d76431 3 weeks ago 
* 5ddbe2d 3 weeks ago 
* ef7e0dc 3 weeks ago 
* 001fba7 3 weeks ago 
* 9c84fd4 3 weeks ago 
* fc79c6d 3 weeks ago 

INFO [06/04/22 12:26:28:32] Working directory: /Users/mmisztal/Checkout/cloudtek/build-system
INFO [06/04/22 12:26:28:37] Project root is: /Users/mmisztal/Checkout/cloudtek/build-system/
INFO [06/04/22 12:26:28:37] DotGit directory is: /Users/mmisztal/Checkout/cloudtek/build-system/.git
INFO [06/04/22 12:26:28:57] Using latest commit on specified branch
INFO [06/04/22 12:26:28:64] Running against branch: release/0.28 (b4f4fea feat: version incremented)
INFO [06/04/22 12:26:28:64] Begin: Calculating base versions
  INFO [06/04/22 12:26:28:67] Fallback base version: 0.1.0 with commit count source fc79c6dde60ee77c48e780ecb4d7eae81c153b61
  INFO [06/04/22 12:26:28:78] Git tag '0.27': 0.27.0 with commit count source 28c02b5138ef7d449eafad5b0a493b7bed51efee
  INFO [06/04/22 12:26:28:78] Git tag '0.25': 0.25.0 with commit count source 255539c8e4e89421aee835dbca16729728a9d8fd
  INFO [06/04/22 12:26:28:78] Git tag '0.24': 0.24.0 with commit count source 962d14832df7ab6555cd1103bf001db7e1e98288
  INFO [06/04/22 12:26:28:78] Git tag '0.23': 0.23.0 with commit count source 32f11247e3261ed6a8c4968acac281bb49c330b1
  INFO [06/04/22 12:26:28:78] Git tag '0.22': 0.22.0 with commit count source 7abb0689a5b3c96330d415583a7b07a61f3ade10
  INFO [06/04/22 12:26:28:78] Git tag '0.21': 0.21.0 with commit count source 00520c491a6a83b1cb2fc2624e92565bc54fea2a
  INFO [06/04/22 12:26:28:78] Begin: Finding branch source of 'release/0.28'
    INFO [06/04/22 12:26:28:81] Begin: Finding merge base between 'release/0.28' and 'main'.
      INFO [06/04/22 12:26:28:83] Found merge base of d47d236 fix: pipeline name updated
      INFO [06/04/22 12:26:28:83] Merge base of release/0.28' and 'main is d47d236 fix: pipeline name updated
    INFO [06/04/22 12:26:28:83] End: Finding merge base between 'release/0.28' and 'main'. (Took: 17.83ms)
  INFO [06/04/22 12:26:28:85] End: Finding branch source of 'release/0.28' (Took: 63.52ms)
  INFO [06/04/22 12:26:28:85] Version in branch name: 0.28.0 with commit count source d47d2368578f4938988dbfc05a48493993769df9
  INFO [06/04/22 12:26:28:94] Found multiple base versions which will produce the same SemVer (0.29.0), taking oldest source for commit counting (Version in branch name)
  INFO [06/04/22 12:26:28:94] Base version used: Version in branch name: 0.28.0 with commit count source d47d2368578f4938988dbfc05a48493993769df9
  INFO [06/04/22 12:26:28:94] End: Calculating base versions (Took: 299.45ms)
  INFO [06/04/22 12:26:28:95] 2 commits found between d47d236 fix: pipeline name updated and b4f4fea feat: version incremented
  INFO [06/04/22 12:26:28:95] 2 commits found between d47d236 fix: pipeline name updated and b4f4fea feat: version incremented
  INFO [06/04/22 12:26:28:95] Begin: Getting version tags from branch 'refs/heads/release/0.28'.
  INFO [06/04/22 12:26:28:97] End: Getting version tags from branch 'refs/heads/release/0.28'. (Took: 17.30ms)
{
  "Major": 0,
  "Minor": 29,
  "Patch": 0,
  "PreReleaseTag": "pre.2",
  "PreReleaseTagWithDash": "-pre.2",
  "PreReleaseLabel": "pre",
  "PreReleaseLabelWithDash": "-pre",
  "PreReleaseNumber": 2,
  "WeightedPreReleaseNumber": 30002,
  "BuildMetaData": null,
  "BuildMetaDataPadded": "",
  "FullBuildMetaData": "Branch.release-0.28.Sha.b4f4feac9b574239f9a21612fa2e0ce15820bb1e",
  "MajorMinorPatch": "0.29.0",
  "SemVer": "0.29.0-pre.2",
  "LegacySemVer": "0.29.0-pre2",
  "LegacySemVerPadded": "0.29.0-pre0002",
  "AssemblySemVer": "0.29.0.0",
  "AssemblySemFileVer": "0.29.0.0",
  "FullSemVer": "0.29.0-pre.2",
  "InformationalVersion": "0.29.0-pre.2+Branch.release-0.28.Sha.b4f4feac9b574239f9a21612fa2e0ce15820bb1e",
  "BranchName": "release/0.28",
  "EscapedBranchName": "release-0-28",
  "Sha": "b4f4feac9b574239f9a21612fa2e0ce15820bb1e",
  "ShortSha": "b4f4fea",
  "NuGetVersionV2": "0.29.0-pre0002",
  "NuGetVersion": "0.29.0-pre0002",
  "NuGetPreReleaseTagV2": "pre0002",
  "NuGetPreReleaseTag": "pre0002",
  "VersionSourceSha": "d47d2368578f4938988dbfc05a48493993769df9",
  "CommitsSinceVersionSource": 2,
  "CommitsSinceVersionSourcePadded": "0002",
  "UncommittedChanges": 0,
  "CommitDate": "2022-05-21"
}
  INFO [06/04/22 12:26:29:08] Done writing 

Possible Fix

Steps to Reproduce

GitVersion.yml

mode: ContinuousDelivery
# Conventional Commits https://www.conventionalcommits.org/en/v1.0.0/
# https://regex101.com/r/Ms7Vx6/2
major-version-bump-message: "(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\\([a-z]+\\))?(!: .+|: (.+\\n\\n)+BREAKING CHANGE: .+)"
# https://regex101.com/r/Oqhi2m/1
minor-version-bump-message: "(feat)(\\([a-z]+\\))?: .+"
# https://regex101.com/r/f5C4fP/1
patch-version-bump-message: "(build|chore|ci|docs|fix|perf|refactor|revert|style|test)(\\([a-z]+\\))?: .+"
# Match nothing
no-bump-message: ^\b$
continuous-delivery-fallback-tag: ''
legacy-semver-padding: 4
build-metadata-padding: 4
branches:
  main:
    regex: ^(main|master)$
    mode: ContinuousDelivery
    tag: ''
    increment: 'Patch'
    is-source-branch-for:
    - release
    - feature
    - hotfix
    prevent-increment-of-merged-branch-version: true
    track-merge-target: false
    tracks-release-branches: false
    is-release-branch: false
    is-mainline: true
    pre-release-weight: 55000
  feature:
    regex: ^feature[/-]
    mode: ContinuousDelivery
    tag: useBranchName
    increment: Inherit
    source-branches: [ 'main', 'release' ]
    prevent-increment-of-merged-branch-version: false
    track-merge-target: false
    tracks-release-branches: false
    is-release-branch: false
    is-mainline: false
    pre-release-weight: 30000
  release:
    regex: ^release[/-]
    mode: ContinuousDeployment
    tag: pre
    source-branches:
    - main
    increment: None
    prevent-increment-of-merged-branch-version: true
    track-merge-target: false
    tracks-release-branches: false
    is-release-branch: true
    is-mainline: false
    pre-release-weight: 30000
  hotfix:
    regex: ^hotfix[/-]
    mode: ContinuousDeployment
    tag: pre
    increment: Patch
    source-branches:
    - main
    prevent-increment-of-merged-branch-version: false
    track-merge-target: false
    tracks-release-branches: false
    is-release-branch: false
    is-mainline: false
    pre-release-weight: 30000
  pull-request:
    regex: ^(pull|pull\-requests|pr)[/-]
    mode: ContinuousDeployment
    tag: pre
    increment: None
    prevent-increment-of-merged-branch-version: false
    tag-number-pattern: '[/-](?<number>\d+)[-/]'
    track-merge-target: false
    source-branches: [ 'main', 'release', 'feature', 'hotfix' ]
    tracks-release-branches: false
    is-release-branch: false
    is-mainline: false
    pre-release-weight: 30000
  support:
    # Match nothing
    regex: ^\b$
  develop:
    # Match nothing
    regex: ^\b$
  • Create a release/* branch git checkout -B release/0.28
  • Create a change and commit it using conventional commits' feat: something feature
  • Run dotnet gitversion

Context

It has incremented the minor version on the release branch, ahead of the release branch's minor version

Your Environment

  • Version Used:
  • Operating System and version (Windows 10, Ubuntu 18.04): MacOS Monterrey
  • Link to your project:
  • Link to your CI build (if appropriate):
@asbjornu
Copy link
Member

asbjornu commented Sep 2, 2022

Are you able to reproduce this in a RepositoryFixture test?

@HHobeck
Copy link
Contributor

HHobeck commented Feb 21, 2023

I tried to reproduce this issue without any success. Thus I'm going to close it. Please reopen this bug or create a new one if you think this bug still persists.

Cheers!

  [Test]
  public void __Just_A_Test__()
  {
      var configuration = GitHubFlowConfigurationBuilder.New.WithSemanticVersionFormat(SemanticVersionFormat.Loose).Build();

      using var fixture = new EmptyRepositoryFixture("release/0.28");
      fixture.MakeACommit("+semver: patch");

      // ✅ succeeds as expected
      fixture.AssertFullSemver("0.28.0-beta.1+1", configuration);
  }

@HHobeck HHobeck closed this as completed Feb 21, 2023
@HHobeck
Copy link
Contributor

HHobeck commented Feb 21, 2023

Okay I can confirm that this behavior is because of the +semver: patch message text. But I'm still not sure what the correct intension is:

[Test]
public void __Just_A_Test__()
{
    var configuration = GitHubFlowConfigurationBuilder.New
        .WithCommitMessageIncrementing(CommitMessageIncrementMode.Enabled)
        .WithSemanticVersionFormat(SemanticVersionFormat.Loose).Build();

    using var fixture = new EmptyRepositoryFixture("main");
    fixture.MakeACommit();
    fixture.BranchTo("release/0.28");
    fixture.MakeACommit("+semver: patch"); // <<---

    // ✅ expected: 0.28.0-beta.1+1 or 0.28.1-beta.1+1 ❔ 
    fixture.AssertFullSemver("0.28.1-beta.1+1", configuration);
}

@HHobeck HHobeck reopened this Feb 21, 2023
@asbjornu
Copy link
Member

asbjornu commented Mar 1, 2023

Thanks for providing a reproduction, @HHobeck! It would be interesting to hear what @mmisztal1980 expects the version to be in that scenario.

@mmisztal1980
Copy link
Author

as per my original post, I was expecting the MINOR version to remain constant and the patch to increase

@HHobeck
Copy link
Contributor

HHobeck commented Mar 4, 2023

The head line was saying something different. That's why I have asked: Minor version increased instead of the prerelease tag ;)

as per my original post, I was expecting the MINOR version to remain constant and the patch to increase

Maybe we need to agree on the naming convention first: If we have a version like 0.28.1-beta.2+3 then it means the following:

  • Major: 0
  • Minor: 28
  • Patch: 1
  • PreReleaseNumber: 2 and
  • CommitsSinceVersionSource: 3

May I ask you again what would be your expecation in the scenario with commit message +semver: patch?

[Test]
public void __Just_A_Test__()
{
    var configuration = GitHubFlowConfigurationBuilder.New
        .WithCommitMessageIncrementing(CommitMessageIncrementMode.Enabled)
        .WithSemanticVersionFormat(SemanticVersionFormat.Loose).Build();

    using var fixture = new EmptyRepositoryFixture("main");
    fixture.MakeACommit();
    fixture.BranchTo("release/0.28");
    fixture.MakeACommit("+semver: patch"); // <<---

    // ✅ expected: 0.28.0-beta.1+1 or 0.28.1-beta.1+1 or 0.28.0-beta.2+1 ❔ 
    fixture.AssertFullSemver("0.28.1-beta.1+1", configuration);
}

@HHobeck HHobeck added this to the 6.x milestone Mar 4, 2023
@HHobeck
Copy link
Contributor

HHobeck commented Mar 15, 2023

The patch nuber increases like the author expecting it. I'm going to close this issue because it has beend solved already in version 6.x. Thank for reporting this issue.

@HHobeck HHobeck closed this as completed Mar 15, 2023
@arturcic arturcic modified the milestones: 6.x, 6.0.0-beta.2 Apr 6, 2023
@arturcic
Copy link
Member

arturcic commented Apr 6, 2023

🎉 This issue has been resolved in version 6.0.0-beta.2 🎉
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