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

[Improvement] Increment version as per source branch #3689

Closed
amardeepprajapati opened this issue Sep 14, 2023 · 6 comments · Fixed by #4009
Closed

[Improvement] Increment version as per source branch #3689

amardeepprajapati opened this issue Sep 14, 2023 · 6 comments · Fixed by #4009

Comments

@amardeepprajapati
Copy link

mode: ContinuousDelivery
assembly-versioning-scheme: MajorMinorPatch
assembly-file-versioning-scheme: MajorMinorPatch
tag-prefix: '[vV]'
continuous-delivery-fallback-tag: ci
major-version-bump-message: '+semver:\s?(breaking|major)'
minor-version-bump-message: '+semver:\s?(feature|minor|feat|enh|enhance|update)'
patch-version-bump-message: '+semver:\s?(fix|patch|hotfix|bugfix|quickfix)'
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:
regex: ^dev?[/-]
mode: ContinuousDeployment
tag: ""
increment: Minor
prevent-increment-of-merged-branch-version: false
track-merge-target: true
source-branches: []
tracks-release-branches: true
is-release-branch: false
is-mainline: false
pre-release-weight: 0

hotfix:
regex: ^fix|hotfix|quickfix|bugfix?[/-]
mode: ContinuousDelivery
tag: beta
increment: Patch
prevent-increment-of-merged-branch-version: false
track-merge-target: true
source-branches: ['develop']
tracks-release-branches: false
is-release-branch: false
is-mainline: false
pre-release-weight: 30000

release:
regex: ^release?[/-]
mode: ContinuousDelivery
tag: ''
increment: Major
prevent-increment-of-merged-branch-version: true
track-merge-target: false
source-branches: []
tracks-release-branches: false
is-release-branch: true
is-mainline: false
pre-release-weight: 30000

ignore:
sha: []
increment: Minor
merge-message-formats: {}
update-build-number: true

====================================================================================================

  • Above version config works as per my use case.
  • But only problem am facing is if a merge any fix|patch|hotfix|bugfix|quickfix to dev it still increments minor version but i want it to increment patch version and for any feature|minor|feat|enh|enhance|update to dev should increment minor version
  • So any push to dev branch can increment minor or patch , if source branch is fix|patch|hotfix|bugfix|quickfix it should increment patch and if source branch is feature|minor|feat|enh|enhance|update it should increment minor
@amardeepprajapati amardeepprajapati changed the title [Improvement] [Improvement] Increment version as per source branch Sep 14, 2023
@HHobeck
Copy link
Contributor

HHobeck commented Sep 18, 2023

May I ask you to create an integration test for this scenario?

[Test]
public void __Just_A_Test__()
{
	var configuration = GitFlowConfigurationBuilder.New.Build();

	using EmptyRepositoryFixture fixture = new("main");

	fixture.MakeACommit();

	// ✔️ succeeded as expected
	fixture.AssertFullSemver("0.0.1-1", configuration);

or

	// ❌ expected 0.1.0-1
	fixture.AssertFullSemver("0.0.1-1", configuration);
}

@amardeepprajapati
Copy link
Author

amardeepprajapati commented Sep 19, 2023

@HHobeck
How can i run this this inside my github workflow ?

@HHobeck
Copy link
Contributor

HHobeck commented Sep 21, 2023

@HHobeck How can i run this this inside my github workflow ?

I'm not sure if I understood your question correct. But integration tests can be executed as part of a unit test framework. It is good for communication and to ensure that the requestor and the implementer have the same understanding about the problem. In advance integration tests can be used to ensure the feature as part as an automated build process.

See src\GitVersion.Core.Tests\IntegrationTests\ on main branch.

@HHobeck HHobeck added this to the 6.x milestone Sep 21, 2023
@arturcic arturcic added stale and removed stale labels Oct 30, 2023
@user1584
Copy link

user1584 commented Dec 7, 2023

As described in #3815, I try to configure GitVersion to follow the GitFlow strategy with as little human versioning as possible. According to the GitVersion documentation, the hotfix branches must be named with the desired version for the main branch after merge (e.g. if main is on "1.2.0", the hotfix branch should be named "hotfix/12.1").
However, I would prefer to use branch names such as "hotfix/put-out-the-fire" without the need to specify the desired main branch version.
Since @HHobeck asked for an integration test, I tried to create one by copy-pasting. Please be aware that I have absolutely no experience with C#!

[Test]
public void UnversionedHotfix()
{
    using var fixture = new BaseGitFlowRepositoryFixture("1.2.0");
    // create hotfix
    Commands.Checkout(fixture.Repository, MainBranch);
    Commands.Checkout(fixture.Repository, fixture.Repository.CreateBranch("hotfix/put-out-the-fire"));
    fixture.Repository.MakeACommit();

    fixture.AssertFullSemver("1.2.1-beta.1+1");
    fixture.Repository.MakeACommit();
    fixture.AssertFullSemver("1.2.1-beta.1+2");

    // Merge hotfix branch to main
    Commands.Checkout(fixture.Repository, MainBranch);

    fixture.Repository.MergeNoFF("hotfix/put-out-the-fire", Generate.SignatureNow());
    fixture.AssertMajorMinorPatch("1.2.1");
}

@HHobeck
Copy link
Contributor

HHobeck commented Jan 28, 2024

To get this behaviour you can use the TrunkBased version strategy as a workaround which will be applied in 6.x.

@arturcic
Copy link
Member

🎉 This issue has been resolved in version 6.0.0-rc.1 🎉
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
Projects
None yet
4 participants