[FEATURE]: Support of prevent increment of merged branch in GitHub workflow
维护者通常 1 天内回复
评估
调研方向
从 MergeMessageVersionStrategy.cs 和 RepositoryFixture 测试开始,然后比较 GitFlowConfigurationBuilder 和 TrunkBasedConfigurationBuilder 的场景。检查 strategies 配置是如何表示的,以及合并分支的 increment 当前是如何启用的。当 GitFlow 和 GitHubFlow 的 acceptance 场景都产生预期的 patch 或 minor increment,并且测试覆盖每种情况时,即表示完成。
由索引模型根据 Issue 内容生成。
描述
Prerequisites
- I have written a descriptive issue title
- I have searched issues to ensure it has not already been reported
GitVersion package
GitVersion.Tool
GitVersion version
6.1.0
Operating system
N/A, Windows
What are you seeing?
The feature to increment the version when merging into a branch by using the increment of the source branch is currently supported only in the TrunkBased workflow. It would be good to have the same behavior in the GitFlow and GitHubFlow workflows as well.
Hint: Needs to be implemented probably in MergeMessageVersionStrategy. We should create a separate version strategy class to be able to enable or disable the behavior via the configuration (strategies property).
What is expected?
Scenario 1:
When merging a hotfix branch with increment patch to a main branch with increment minor, I would expect the increment to be patch and not minor in a GitFlow workflow.
Scenario 2:
When merging a feature branch with increment minor to a main branch with increment patch, I would expect the increment to be minor and not patch in a GitFlow workflow.
Steps to Reproduce
Scenario 1:
* 54 minutes ago (HEAD -> main)
|\
| A 56 minutes ago (hotfix/foo)
|/
* 58 minutes ago (tag: 1.0.0)
Scenario 2:
* 54 minutes ago (HEAD -> main)
|\
| A 56 minutes ago (feature/foo)
|/
* 58 minutes ago (tag: 1.0.0)
See RepostioryFixture Test section below for more information.
RepositoryFixture Test
[Test]
public void Given_main_with_increment_minor_and_hotfix_with_increment_patch_When_hotfix_merged_into_main_Then_increment_should_be_patch()
{
using var fixture = new EmptyRepositoryFixture("main");
var configurationBuilder = TrunkBasedConfigurationBuilder.New
.WithBranch("main", builder => builder
.WithIncrement(IncrementStrategy.Minor)
.WithDeploymentMode(DeploymentMode.ContinuousDelivery)
.WithPreventIncrementOfMergedBranch(true)
).WithBranch("hotfix", builder => builder.WithIncrement(IncrementStrategy.Patch));
fixture.MakeATaggedCommit("1.0.0");
fixture.BranchTo("hotfix/foo");
fixture.MakeACommit();
fixture.MergeTo("main");
// ✅ succeeds as expected
fixture.AssertFullSemver("1.0.1-2", configurationBuilder.Build());
}
It would be good to have the same behavior in the GitFlow and GitHubFlow workflows:
[Test]
public void Given_main_with_increment_minor_and_hotfix_with_increment_patch_When_hotfix_merged_into_main_Then_increment_should_be_patch()
{
using var fixture = new EmptyRepositoryFixture("main");
var configurationBuilder = GitFlowConfigurationBuilder.New
.WithBranch("main", builder => builder.WithIncrement(IncrementStrategy.Minor).WithPreventIncrementOfMergedBranch(true))
.WithBranch("hotfix", builder => builder.WithIncrement(IncrementStrategy.Patch));
fixture.MakeATaggedCommit("1.0.0");
fixture.BranchTo("hotfix/foo");
fixture.MakeACommit();
fixture.MergeTo("main");
// ❔ expected: "1.0.1-2"
fixture.AssertFullSemver("1.1.0-2", configurationBuilder.Build());
}
Additional acceptance criteria:
[Test]
public void Given_main_with_increment_patch_and_feature_with_increment_minor_When_feature_merged_into_main_Then_increment_should_be_minor()
{
using var fixture = new EmptyRepositoryFixture("main");
var configurationBuilder = GitFlowConfigurationBuilder.New
.WithBranch("main", builder => builder
.WithIncrement(IncrementStrategy.Patch)
.WithPreventIncrementOfMergedBranch(true)
).WithBranch("feature", builder => builder.WithIncrement(IncrementStrategy.Minor));
fixture.MakeATaggedCommit("1.0.0");
fixture.BranchTo("feature/foo");
fixture.MakeACommit();
fixture.MergeTo("main");
// ❔ expected: "1.1.0-2"
fixture.AssertFullSemver("1.0.1-2", configurationBuilder.Build());
}
Output log or link to your CI build (if appropriate).
N/A
- 主要语言
- C#
- 星标
- 3.1k
- 派生
- 661
- 平均合并
- 7 小时 4 分钟
- 30 天内合并 PR
- 77
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
GitTools/GitVersion 的其他 Issue
-
[ISSUE]: Mainline: version on main falls back to 0.0.x when a branch named in a merge message still exists可能已有人在做 @arturcic 于 39 天前认领。 未关闭bug
难度 4/5 3-5 天 新手友好度 35/100
GitTools/GitVersion#5405 · 1 条评论 ·
维护者通常 1 天内回复
-
feature
难度 5/5 一周以上 新手友好度 35/100
GitTools/GitVersion#5398 · 1 条评论 ·
维护者通常 1 天内回复
-
bug
难度 4/5 3-5 天 新手友好度 48/100
GitTools/GitVersion#5267 · 2 条评论 ·
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 30/100
GitTools/GitVersion#5188 ·
维护者通常 1 天内回复
-
breaking change pinned
难度 5/5 一周以上 新手友好度 20/100
GitTools/GitVersion#5137 · 2 条评论 ·
维护者通常 1 天内回复
查看 GitTools/GitVersion 的全部 Issue
相似的 Issue
-
documentation
难度 2/5 1-3 小时 新手友好度 85/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
-
area/backend type/bug
难度 2/5 1-3 小时 新手友好度 72/100
umbraco/Umbraco-CMS#24668 · 1 条评论 ·
维护者通常 1 天内回复
-
Pri3
难度 2/5 1-3 小时 新手友好度 72/100
MicrosoftDocs/windows-dev-docs#6205 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
维护者通常 1 天内回复