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

feat: Incrementing patch instead minor #2691

Closed
allanalves23 opened this issue May 16, 2021 · 9 comments · Fixed by #3034
Closed

feat: Incrementing patch instead minor #2691

allanalves23 opened this issue May 16, 2021 · 9 comments · Fixed by #3034
Labels
Milestone

Comments

@allanalves23
Copy link

allanalves23 commented May 16, 2021

When writing commit messages to feat changes, only minor version is incremented.
Ex: On version 1.0.0
Create a commit with message: "feat: Some feature."

Expected Behavior

The version should be 1.1.0

Actual Behavior

The version is 1.0.1

Steps to Reproduce

1 - Clone the repo: https://github.com/allanalves23/gitversion-minor-bug-fixture
2 - Download command line tool: https://gitversion.net/docs/usage/cli/installation
3 - On master branch create any change and create one commit: "feat: should be 1.1.0"
4 - Check version with command dotnet-gitversion

Output of dotnet-gitversion before feat commit:

{
  "Major": 1,
  "Minor": 0,
  "Patch": 0,
  "PreReleaseTag": "1",
  "PreReleaseTagWithDash": "",
  "PreReleaseLabel": "",
  "PreReleaseLabelWithDash": "",
  "PreReleaseNumber": null,
  "WeightedPreReleaseNumber": 60000,
  "BuildMetaData": null,
  "BuildMetaDataPadded": "",
  "FullBuildMetaData": "Branch.master.Sha.7472e6fd0cb3565e91b5cc22a7f57c4d589dcf82",
  "MajorMinorPatch": "1.0.0",
  "SemVer": "1.0.0",
  "LegacySemVer": "1.0.0",
  "LegacySemVerPadded": "1.0.0",
  "AssemblySemVer": "1.0.0.0",
  "AssemblySemFileVer": "1.0.0.0",
  "FullSemVer": "1.0.0",
  "InformationalVersion": "1.0.0+Branch.master.Sha.7472e6fd0cb3565e91b5cc22a7f57c4d589dcf82",
  "BranchName": "master",
  "EscapedBranchName": "master",
  "Sha": "7472e6fd0cb3565e91b5cc22a7f57c4d589dcf82",
  "ShortSha": "7472e6f",
  "NuGetVersionV2": "1.0.0",
  "NuGetVersion": "1.0.0",
  "NuGetPreReleaseTagV2": "",
  "NuGetPreReleaseTag": "",
  "VersionSourceSha": "e79e24b2cc466ddd1d5138c8488aca389c171a79",
  "CommitsSinceVersionSource": 1,
  "CommitsSinceVersionSourcePadded": "0001",
  "UncommittedChanges": 0,
  "CommitDate": "2021-05-16"
}

Output of dotnet-gitversion after feat commit:

{
  "Major": 1,
  "Minor": 0,
  "Patch": 1,
  "PreReleaseTag": "2",
  "PreReleaseTagWithDash": "",
  "PreReleaseLabel": "",
  "PreReleaseLabelWithDash": "",
  "PreReleaseNumber": null,
  "WeightedPreReleaseNumber": 60000,https://github.com/allanalves23/gitversion-minor-bug-fixture
  "BuildMetaData": null,
  "BuildMetaDataPadded": "",
  "FullBuildMetaData": "Branch.master.Sha.9b03dd2ceaa5a73a784c0bcd100e722643adaa8a",
  "MajorMinorPatch": "1.0.1",
  "SemVer": "1.0.1",
  "LegacySemVer": "1.0.1",
  "LegacySemVerPadded": "1.0.1",
  "AssemblySemVer": "1.0.1.0",
  "AssemblySemFileVer": "1.0.1.0",
  "FullSemVer": "1.0.1",
  "InformationalVersion": "1.0.1+Branch.master.Sha.9b03dd2ceaa5a73a784c0bcd100e722643adaa8a",
  "BranchName": "master",
  "EscapedBranchName": "master",
  "Sha": "9b03dd2ceaa5a73a784c0bcd100e722643adaa8a",
  "ShortSha": "9b03dd2",
  "NuGetVersionV2": "1.0.1",
  "NuGetVersion": "1.0.1",
  "NuGetPreReleaseTagV2": "",
  "NuGetPreReleaseTag": "",
  "VersionSourceSha": "e79e24b2cc466ddd1d5138c8488aca389c171a79",
  "CommitsSinceVersionSource": 2,
  "CommitsSinceVersionSourcePadded": "0002",
  "UncommittedChanges": 0,
  "CommitDate": "2021-05-16"
}

Screenshot after feat commit:

Screenshot from 2021-05-16 20-13-36

GitVersion.yml are on project below.

@asbjornu
Copy link
Member

asbjornu commented Mar 7, 2022

Conventional commits aren't supported out of the box, you need to configure it. I've created #3034 to make this easier to find in the documentation.

@allanalves23
Copy link
Author

allanalves23 commented Mar 7, 2022

Its already configured, the settings are on GitVersion.yml.

mode: Mainline
major-version-bump-message: '\BREAKING CHANGE:\s?'
minor-version-bump-message: '\feat:\s?'
patch-version-bump-message: '\fix:\s?'
commit-message-incrementing: Enabled
branches:
  master:
    regex: ^latest$|^master$|^main$|^release$
  pull-request:
    tag: pr

the keyword fix doesn't work to increment patch version.

@asbjornu
Copy link
Member

asbjornu commented Mar 7, 2022

That is curious. What you've described above is that feat: doesn't increment minor? As you can see, we have quite a few test cases which should ensure that this is working:

[Theory]
[TestCase("build: Cleaned up various things", "1.0.1")]
[TestCase("build: Cleaned up various things\n\nSome descriptive text", "1.0.1")]
[TestCase("build: Cleaned up various things\n\nSome descriptive text\nWith a second line", "1.0.1")]
[TestCase("build(ref): Cleaned up various things", "1.0.1")]
[TestCase("build(ref)!: Major update", "2.0.0")]
[TestCase("chore: Cleaned up various things", "1.0.1")]
[TestCase("ci: Cleaned up various things", "1.0.1")]
[TestCase("docs: Cleaned up various things", "1.0.1")]
[TestCase("fix: Cleaned up various things", "1.0.1")]
[TestCase("perf: Cleaned up various things", "1.0.1")]
[TestCase("refactor: Cleaned up various things", "1.0.1")]
[TestCase("revert: Cleaned up various things", "1.0.1")]
[TestCase("style: Cleaned up various things", "1.0.1")]
[TestCase("test: Cleaned up various things", "1.0.1")]
[TestCase("feat(ref): Simple feature", "1.1.0")]
[TestCase("feat(ref)!: Major update", "2.0.0")]
[TestCase("feat: Major update\n\nSome descriptive text\n\nBREAKING CHANGE: A reason", "2.0.0")]
[TestCase("feat: Major update\n\nSome descriptive text\n\nBREAKING CHANGE Missing colon", "1.1.0")]
[TestCase("feat: Major update\n\nForgot to describe the change\n\nBREAKING CHANGE: ", "1.1.0")]
[TestCase("feat: Major update\n\nBREAKING CHANGE: A reason", "2.0.0")]
[TestCase("feat: Major update\n\nSome descriptive text\nWith a second line\n\nBREAKING CHANGE: A reason", "2.0.0")]
public void CanUseConventionalCommitsToBumpVersion(string commitMessage, string expectedVersion)
{
var configuration = new Config
{
VersioningMode = VersioningMode.Mainline,
// For future debugging of this regex: https://regex101.com/r/CRoBol/2
MajorVersionBumpMessage = "^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\\([\\w\\s-]*\\))?(!:|:.*\\n\\n((.+\\n)+\\n)?BREAKING CHANGE:\\s.+)",
// For future debugging of this regex: https://regex101.com/r/9ccNam/3
MinorVersionBumpMessage = "^(feat)(\\([\\w\\s-]*\\))?:",
// For future debugging of this regex: https://regex101.com/r/oFpqxA/2
PatchVersionBumpMessage = "^(build|chore|ci|docs|fix|perf|refactor|revert|style|test)(\\([\\w\\s-]*\\))?:"
};
using var fixture = new EmptyRepositoryFixture();
fixture.Repository.MakeACommit();
fixture.MakeATaggedCommit("1.0.0");
fixture.Repository.MakeACommit(commitMessage);
fixture.AssertFullSemver(expectedVersion, configuration);
}

@gep13
Copy link
Member

gep13 commented Mar 8, 2022

@asbjornu in this case, isn't \f in the regex looking for a form feed?

Should the minor-version-bump-message not simply be: fix:\s??

@allanalves23
Copy link
Author

That is curious. What you've described above is that feat: doesn't increment minor? As you can see, we have quite a few test cases which should ensure that this is working

Sorry @asbjornu, i mean feat not incrementing minor, not fix.

I'm reproduce the bug again, i will return soon.

@asbjornu
Copy link
Member

asbjornu commented Mar 8, 2022

@asbjornu in this case, isn't \f in the regex looking for a form feed?

Should the minor-version-bump-message not simply be: fix:\s??

@gep13, good catch! Yeah, the initial backslash looks like an error. Why did you put it there, @allanalves23? Please use the conventional commit regexes we have documented:

mode: MainLine # Only add this if you want every version to be created automatically on your main branch.
major-version-bump-message: "^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\\([\\w\\s-]*\\))?(!:|:.*\\n\\n((.+\\n)+\\n)?BREAKING CHANGE:\\s.+)"
minor-version-bump-message: "^(feat)(\\([\\w\\s-]*\\))?:"
patch-version-bump-message: "^(build|chore|ci|docs|fix|perf|refactor|revert|style|test)(\\([\\w\\s-]*\\))?:"

@allanalves23
Copy link
Author

@asbjornu this works perfectly.

image

My GitVersion.yml

mode: MainLine # Only add this if you want every version to be created automatically on your main branch.

major-version-bump-message: "^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\\([\\w\\s-]\\))?(!:|:.\\n\\n((.+\\n)+\\n)?BREAKING CHANGE:\\s.+)"
minor-version-bump-message: "^(feat)(\\([\\w\\s-]*\\))?:"
patch-version-bump-message: "^(build|chore|ci|docs|fix|perf|refactor|revert|style|test)(\\([\\w\\s-]*\\))?:"

branches:
  master:
    regex: ^latest$|^master$|^main$|^release$
  pull-request:
    tag: pr

Thx @asbjornu and @gep13 !!

@asbjornu
Copy link
Member

asbjornu commented Mar 8, 2022

@allanalves23, awesome! 👍🏼

@arturcic arturcic modified the milestones: 5.x, 5.9.0 Mar 10, 2022
@github-actions
Copy link

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

Successfully merging a pull request may close this issue.

4 participants