-
Notifications
You must be signed in to change notification settings - Fork 650
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
[Feature] Patch version not incrementing based on commit message #3494
Comments
I think for trunk based (also known as main line) scenarios the behavior of incrementing only one time makes no sense. It might be a option to change this constraint for mainline mode. @asbjornu What do you think? |
As I don't use mainline mode myself, I don't really know what people expect here. Some seem to expect that commit message incrementation coalesces and some that they add up. I have no idea what's "right". For now, I think we should do as I write in #3097 (comment) and document the current behavior better. The next step would be to consider either changing the behavior depending on the chosen If we allow this behavior to be configured, we can either use the existing All names are of course open for debate, these are just the first that came to my head. Thoughts? |
FWIW and simply as an example of a similar tool, there is a Gradle plugin for SemVer calculation which provides both options (coalesce and sum), which is controlled by a property in the build file. The default is to coalesce so that multiple feature/patch commits only increment the minor/patch by 1. Personally, I believe this to be the majority use case as, IMO, it makes the most sense. However, I can certainly see cases where each feature or fix commit could warrant an increment in the version numbers. Having the ability to do either is certainly a worthwhile addition, and clearly document what the default option would be. The |
Okay good idea to make it configurable. Then I change this issue from bug to feature and move it to the milestone 7.x. |
Hey guys, thanks for all the answers. However what I am confused about is that nothing gets incremented at all. I'm not talking about multiple increments of the Patch version for the same feature branch, for me it does not increment it even once.
Looking at the documentation, However now I created a feature branch, added some changes and merged it to |
Please try the latest development stage (master branch) and let me know if this behavior still persists. In advance please provide an integration test for your scenario like: [Test]
public void ShouldProvideTheCorrectVersionEvenIfPreReleaseLabelExistsInTheGitTagMain()
{
var configuration = GitFlowConfigurationBuilder.New
.WithNextVersion("5.0")
.WithSemanticVersionFormat(SemanticVersionFormat.Loose)
.WithBranch("main", _ => _
.WithLabel("beta")
.WithIncrement(IncrementStrategy.Patch)
.WithVersioningMode(VersioningMode.ContinuousDeployment)
.WithIsMainline(false)
).Build();
using EmptyRepositoryFixture fixture = new("main");
fixture.MakeACommit();
// ✅ succeeds as expected
fixture.AssertFullSemver("5.0.0-beta.1", configuration);
fixture.MakeACommit();
// ✅ succeeds as expected
fixture.AssertFullSemver("5.0.0-beta.2", configuration);
fixture.ApplyTag("5.0.0-beta.3");
// ✅ succeeds as expected
fixture.AssertFullSemver("5.0.0-beta.3", configuration);
fixture.MakeATaggedCommit("5.0.0-rc.1");
// ✅ succeeds as expected
fixture.AssertFullSemver("5.0.0-beta.4", configuration);
fixture.MakeACommit();
// ✅ succeeds as expected
fixture.AssertFullSemver("5.0.0-beta.5", configuration);
} If you not fimiliar with it please use the released version 6.0.0-beta.2 (keep in mind that the configuration has been changed) and provide exactly the steps to reproduce (git commands?). Thank you very much. |
I am not familiar with the testing framework, how do I import the necessary namespaces? I installed the tool in a docker image like so:
Thank you! |
Hi there. If you want to execute or create new integration tests please download the source code and build the source: https://github.com/GitTools/GitVersion/releases/tag/6.0.0-beta.2 You will find the tests in GitVersion.Core.Tests project. |
Hi, I managed to build and execute some tests, especially the one you shared above. The test passes however that still does not offer more clarity as to why I cannot increase the patch version of the
Also with this different configuration:
My test fails with the following asserts:
|
To your first unit test I can say it has been already answered: see #3097 (comment) and the comments above. |
To the second unit test: If you use bump messages then it's better to not use next-version at least for mainline mode (I think it is a bug in the implementation). In advance I'm not sure if the usage of pre-release label on a mainline branch makes sense. I thougth mainline alias trunkbased workflow not using tags at all? Please try this: [Test]
public void __Just_A_Test__()
{
var configuration = GitFlowConfigurationBuilder.New
//.WithNextVersion("1.0.0") // <<-- This does not play well with bump messages
.WithSemanticVersionFormat(SemanticVersionFormat.Loose)
.WithCommitMessageIncrementing(CommitMessageIncrementMode.Enabled)
.WithBranch("main", _ => _
.WithLabel("beta")
.WithVersioningMode(VersioningMode.Mainline)
.WithIncrement(IncrementStrategy.Minor)
).Build();
using EmptyRepositoryFixture fixture = new("main");
fixture.MakeATaggedCommit("1.0.0");
// expected 1.0.0 or 1.1.0-beta.0
fixture.AssertFullSemver("1.0.0-beta.0", configuration);
fixture.MakeACommit();
// ✅ succeeds as expected
fixture.AssertFullSemver("1.1.0-beta.1", configuration);
fixture.ApplyTag("1.1.0");
// expected 1.1.0 or 1.2.0-beta.0
fixture.AssertFullSemver("1.1.0-beta.0", configuration);
fixture.MakeACommit("testing +semver: fix");
// ✅ succeeds as expected
fixture.AssertFullSemver("1.1.1-beta.1", configuration);
fixture.CreateBranch("feature/add_scripts");
fixture.MakeACommit("Adding my scripts, +semver:patch");
fixture.Checkout("main");
fixture.MergeNoFF("feature/add_scripts");
// ✅ succeeds as expected
fixture.AssertFullSemver("1.1.2-beta.2", configuration);
} |
Thanks for sharing that information @wmclifford, it's very helpful to know how other tools deal with the same problems.
👍🏼
We would keep |
Hi there, so I tried out the latest test and it works - that made me to realize I need to use the I did these changes on my current repo, also added a new tag since I wanted to have consistency that was missing due to my earlier mistakes, built the project on CI and the gitversion was exactly what I hoped and expected. Here's the output of running
Also I attached the used Thanks for all your help! |
Please write an integration test for your scenario with actual and exptected version annotation... Otherwise I cannot follow your thoughts. |
The bump message increment behaves different depending on whether you run it on branches with mainline or non-mainline mode. In this case I expect you are in a branch with ContinuousDelivery mode with increment Patch and complaining about that nothing happened when creating a message with semver+: patch right!? The bump message feature like it is implemented in the actual version of git-version is there to bump the increment to a higher value for the calculation of the next version. If lets say the base version is 1.0.0 then the following matrix applies: A commit without a bump message yields:
A commit with semver+: patch message yields
A commit with semver+: minor message yields
A commit with semver+: major message yields
May I ask you: Why would you bump the version e.g. the patch version to 1.0.2 and skip the version 1.0.1 without releasing it? |
What I'm trying to say is you need to think about the use case of using the bump message feature. The motivation is more dependent on what changes your commit includes from the development perspective. When you in the role of a developer don't care about what the target branch might be and think: "Oh it's not just a minor change it’s a huge change which should yield to a major version increment because I have updated the API with a breaking change." Hope that's understandable. |
Hi, I tried to write a test to replicate the situation that I have and am expecting:
Changing the
Furthermore changing the branch to be
gives this error message
which makes me think that somehow the Mainline mode doesn't support using a branch called
In a way I am doing a release (maybe I misunderstand the term however) since everytime the
It's true that the development workflow influences a lot the way the versions get changed however I think each developer has his own way of working and while someone might add their changes in 4 different branches vs someone who adds it into 1 single one depends a lot on the context and the situation. Thanks a lot for your help and patience though! :) |
Okay I think you have a fundamental misunderstanding about the common used branching and merging strategies. This is in most cases the git hub flow or the git flow and in my opinion the trunk based workflow (of course there are maybe more out there but this is mainly supported by git version). I would recommend you to take a look to the following documentation: https://gitversion.net/docs/learn/branching-strategies/ |
GitVersion is a tool to generate the sematic version based on the current state of your git repository. Each version increment (independent of whether you change the major, minor or patch number) means you have a new version of a product with dedicated bugfixes and features. If you are planning a feature release e.g. 1.1.0 then you of course create sometimes release candidates for testing purpose or whatever. This release candidates normally are labeled with a pre-release name and/or number. If you take the git flow workflow an think about the following scenario:
then you see that pre-release number (aliase revision number) is used for that purpose. |
Hi, For example, with the current state of my local repo I get the current semver output:
After merging a branch into
It's the same SHA, same commit, same branch in both outputs. If Thank you! |
No it's highly dependent on which branch you are. |
May I ask you is this discussion related to the initial issue you have posted or are you trying to implement your custom workflow and want just help? I'm asking because for that we have a dedicated question issue item you should use instead. Thank you! |
Hi @HHobeck |
Describe the bug
It seems the patch version does not increment properly based on commit message keywords. It seemed to work when I tested it last month but now I'm having some issues with this.
Expected Behavior
Doing a commit with the keywords
+semver:fix additional text
or+semver:patch additional text
should increase the patch version.For example the current gitversion is
1.0.1-dev.19
, I do agit commit --allow-empty -m "added a fix for bug +semver:fix"
I expect the next gitversion to be
1.0.2-dev.20
.Actual Behavior
Following the example from above, the actual gitversion generates:
1.0.1-dev.20
Context
I am trying to use gitversion for setting the version of a pip library automatically. Initially when I tested it I had some issues with incrementing the patch value that went away after I removed the
next-version
flag fromGitVersion.yml
.Furthermore I had issues due to some existing incompatibilities between gitversion and PEP440 specification so I needed to tweak the tags that get generated by gitversion. Finally I decided to just use the Major.Minor.Patch version so there are no more complications.
I added a tag v1.0.0 on my feature branch that introduced support for gitversion such that all future versions are computed from that.
So now my
devel
branch has gitversion:1.0.1
.I want to merge in a feature branch that adds some additional scripts and I added in one of the commit messages
+semver:fix
but it did not change the Patch value.Maybe I am misunderstanding the way the keywords in commit messages are impacting the generated SemVer but my impression is that if I have a feature branch that starts at version
1.0.1
and I do 3 commits and 2 of those commits contain the+semver: fix
keyword, the version I should get when I merge the PR into devel should be at least1.0.3
.Your Environment
Using unix-based environment, however
gitversion
tool is running inside a docker container.Version of
gitversion /version
:5.10.3+Branch.support-5.x.Sha.bc9c9d003e655385e3dd1ba3bd013e04062d2f9b
My
GitVersion.yml
file looks like this:The text was updated successfully, but these errors were encountered: