GitVersion
GitVersion copied to clipboard
[Improvement] Increment version as per source branch
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
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);
}
@HHobeck How can i run this this inside my github workflow ?
@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.
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");
}
To get this behaviour you can use the TrunkBased version strategy as a workaround which will be applied in 6.x.
:tada: This issue has been resolved in version 6.0.0-rc.1 :tada: The release is available on:
Your GitReleaseManager bot :package::rocket: