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

Manually incrementing the version #2917

Closed
pampua84 opened this issue Nov 12, 2021 · 13 comments
Closed

Manually incrementing the version #2917

pampua84 opened this issue Nov 12, 2021 · 13 comments
Labels
Milestone

Comments

@pampua84
Copy link
Contributor

Hello to all,
I'm trying to manually update the patch version with a commit message like this:

_ "New class added. + Semver: patch" _

i am using ContinuousDeployment mode, this is the default configuration file:

assembly-versioning-scheme: MajorMinorPatch
assembly-file-versioning-scheme: MajorMinorPatch
mode: ContinuousDeployment
tag-prefix: '[vV]'
continuous-delivery-fallback-tag: ci
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)'
legacy-semver-padding: 4
build-metadata-padding: 4
commits-since-version-source-padding: 4
tag-pre-release-weight: 60000
commit-message-incrementing: Enabled
branches:
  develop:
    mode: ContinuousDeployment
    tag: alpha
    increment: Minor
    prevent-increment-of-merged-branch-version: false
    track-merge-target: true
    regex: ^dev(elop)?(ment)?$
    source-branches: []
    tracks-release-branches: true
    is-release-branch: false
    is-mainline: false
    pre-release-weight: 0
  main:
    mode: ContinuousDeployment
    tag: ''
    increment: Patch
    prevent-increment-of-merged-branch-version: true
    track-merge-target: false
    regex: ^master$|^main$
    source-branches:
    - develop
    - release
    tracks-release-branches: false
    is-release-branch: false
    is-mainline: true
    pre-release-weight: 55000
  release:
    mode: ContinuousDeployment
    tag: beta
    increment: None
    prevent-increment-of-merged-branch-version: true
    track-merge-target: false
    regex: ^releases?[/-]
    source-branches:
    - develop
    - main
    - support
    - release
    tracks-release-branches: false
    is-release-branch: true
    is-mainline: false
    pre-release-weight: 30000
  feature:
    mode: ContinuousDeployment
    tag: useBranchName
    increment: Inherit
    prevent-increment-of-merged-branch-version: false
    track-merge-target: false
    regex: ^features?[/-]
    source-branches:
    - develop
    - main
    - release
    - feature
    - support
    - hotfix
    tracks-release-branches: false
    is-release-branch: false
    is-mainline: false
    pre-release-weight: 30000
  pull-request:
    mode: ContinuousDeployment
    tag: PullRequest
    increment: Inherit
    prevent-increment-of-merged-branch-version: false
    tag-number-pattern: '[/-](?<number>\d+)'
    track-merge-target: false
    regex: ^(pull|pull\-requests|pr)[/-]
    source-branches:
    - develop
    - main
    - release
    - feature
    - support
    - hotfix
    tracks-release-branches: false
    is-release-branch: false
    is-mainline: false
    pre-release-weight: 30000
  hotfix:
    mode: ContinuousDeployment
    tag: beta
    increment: Patch
    prevent-increment-of-merged-branch-version: false
    track-merge-target: false
    regex: ^hotfix(es)?[/-]
    source-branches:
    - develop
    - main
    - support
    tracks-release-branches: false
    is-release-branch: false
    is-mainline: false
    pre-release-weight: 30000
  support:
    mode: ContinuousDeployment
    tag: ''
    increment: Patch
    prevent-increment-of-merged-branch-version: true
    track-merge-target: false
    regex: ^support[/-]
    source-branches:
    - main
    tracks-release-branches: false
    is-release-branch: false
    is-mainline: true
    pre-release-weight: 55000
ignore:
  sha: []
commit-date-format: yyyy-MM-dd
merge-message-formats: {}
update-build-number: true

and this is my GitVersion.yml file:

mode: ContinuousDeployment
next-version: 1.0.0
branches: {}
ignore:
  sha: []
merge-message-formats: {}

but this doesn't work. I have installed gitversion.tool version '5.7.0'.

Thanks

@pampua84 pampua84 added the bug label Nov 12, 2021
@asbjornu
Copy link
Member

asbjornu commented Nov 12, 2021

Have you tried mode: Mainline or commit-message-incrementing: Enabled?

@pampua84
Copy link
Contributor Author

Hi @asbjornu, unfortunately it doesn't even work in mainline mode,but it should also work in ContinuousDeployment mode, at least so it is specified in the doc.

@asbjornu
Copy link
Member

asbjornu commented Mar 2, 2022

Sounds like this should be possible to reproduce in a test. Could you please create one in a PR?

@pampua84
Copy link
Contributor Author

What exactly do you mean by creating a test in the Pull Request?

@asbjornu
Copy link
Member

Something like this:

[Test]
public void MergedFeatureBranchesToMainImpliesRelease()
{
using var fixture = new EmptyRepositoryFixture();
fixture.Repository.MakeACommit("1");
fixture.MakeATaggedCommit("1.0.0");
fixture.BranchTo("feature/foo", "foo");
fixture.MakeACommit("2");
fixture.AssertFullSemver("1.0.1-foo.1", this.config);
fixture.MakeACommit("2.1");
fixture.AssertFullSemver("1.0.1-foo.2", this.config);
fixture.Checkout(MainBranch);
fixture.MergeNoFF("feature/foo");
fixture.AssertFullSemver("1.0.1", this.config);
fixture.BranchTo("feature/foo2", "foo2");
fixture.MakeACommit("3 +semver: minor");
fixture.AssertFullSemver("1.1.0-foo2.1", this.config);
fixture.Checkout(MainBranch);
fixture.MergeNoFF("feature/foo2");
fixture.AssertFullSemver("1.1.0", this.config);
fixture.BranchTo("feature/foo3", "foo3");
fixture.MakeACommit("4");
fixture.Checkout(MainBranch);
fixture.MergeNoFF("feature/foo3");
fixture.SequenceDiagram.NoteOver("Merge message contains '+semver: minor'", MainBranch);
var commit = fixture.Repository.Head.Tip;
// Put semver increment in merge message
fixture.Repository.Commit(commit.Message + " +semver: minor", commit.Author, commit.Committer, new CommitOptions { AmendPreviousCommit = true });
fixture.AssertFullSemver("1.2.0", this.config);
fixture.BranchTo("feature/foo4", "foo4");
fixture.MakeACommit("5 +semver: major");
fixture.AssertFullSemver("2.0.0-foo4.1", this.config);
fixture.Checkout(MainBranch);
fixture.MergeNoFF("feature/foo4");
fixture.AssertFullSemver("2.0.0", this.config);
// We should evaluate any commits not included in merge commit calculations for direct commit/push or squash to merge commits
fixture.MakeACommit("6 +semver: major");
fixture.AssertFullSemver("3.0.0", this.config);
fixture.MakeACommit("7 +semver: minor");
fixture.AssertFullSemver("3.1.0", this.config);
fixture.MakeACommit("8");
fixture.AssertFullSemver("3.1.1", this.config);
// Finally verify that the merge commits still function properly
fixture.BranchTo("feature/foo5", "foo5");
fixture.MakeACommit("9 +semver: minor");
fixture.AssertFullSemver("3.2.0-foo5.1", this.config);
fixture.Checkout(MainBranch);
fixture.MergeNoFF("feature/foo5");
fixture.AssertFullSemver("3.2.0", this.config);
// One more direct commit for good measure
fixture.MakeACommit("10 +semver: minor");
fixture.AssertFullSemver("3.3.0", this.config);
// And we can commit without bumping semver
fixture.MakeACommit("11 +semver: none");
fixture.AssertFullSemver("3.3.0", this.config);
Console.WriteLine(fixture.SequenceDiagram.GetDiagram());
}

@pampua84
Copy link
Contributor Author

I created the test, the first increment works, the second doesn't and the test fails.

@pampua84
Copy link
Contributor Author

pampua84 commented Apr 7, 2022

Hi @asbjornu are there any updates about it? Thanks

@asbjornu
Copy link
Member

I haven't investigated what the difference between your submitted (failing) test and the existing (successful) test. But you can see that your use-case should be working in the following test:

fixture.AssertFullSemver("1.1.0", minorIncrementConfig);
fixture.BranchTo("feature/foo2", "foo2");
fixture.MakeACommit("3 +semver: patch");
fixture.AssertFullSemver("1.1.1-foo2.1", minorIncrementConfig);

@pampua84
Copy link
Contributor Author

pampua84 commented May 3, 2022

Hi @asbjornu in my test case I have two consecutive increments, the first increment passes the test, the second does not because the patch remains the same:

fixture.BranchTo("development", "development");
fixture.MakeACommit("2 +semver: patch");

fixture.AssertFullSemver("0.1.1-alpha.1", this.config);   // Test pass

fixture.MakeACommit("3 +semver: patch");

fixture.AssertFullSemver("0.1.2-alpha.2", this.config);  // Test failed

Is there any reason why I can't do this?
Thanks

@asbjornu
Copy link
Member

asbjornu commented May 4, 2022

I see. No, I don't see a good reason why this shouldn't be possible. Pull requests are welcome.

@HHobeck HHobeck added this to the 6.x milestone Mar 18, 2023
HHobeck added a commit to HHobeck/GitVersion that referenced this issue Mar 18, 2023
@HHobeck
Copy link
Contributor

HHobeck commented Mar 18, 2023

I think this issue is related to #3097. I saw the following comment from orionstudt:

AFAIK this is expected behavior. If your release has multiple features you don't increment the minor N times for every feature, you increment it once. If you want to increment the minor version again, you need to tell it that it is the next release by tagging with 1.5.0

@HHobeck
Copy link
Contributor

HHobeck commented Mar 20, 2023

I think this is not a bug and the actual behavior is intentional.

@HHobeck HHobeck closed this as completed Mar 20, 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