GitVersion 的 +semver 命令如何工作?

lad*_*dge 4 git git-flow gitversion

我正在尝试使用GitVersion+semver:patch命令来更改我的补丁版本号,但它没有按我预期的方式工作。

我的master分支上有一个标签“2.2.0”。我在我的开发分支上做出了以下承诺:

b5d9f141  (HEAD -> develop, origin/develop) +semver:patch
75122489  Added unit test. +semver:patch
3b4e7eef  (tag: 2.2.0, origin/master, master) Merge branch 'release/2.2.0'
Run Code Online (Sandbox Code Playgroud)

我正在关注GitFlow。在最近两次提交之后,我希望我的版本报告为 2.3.2,但 GitVersion 仍然将其报告为 2.3.0。

"主要次要补丁":"2.3.0"

它是如何+semver工作的,有没有什么方法可以按照我想要的方式仅使用提交消息来提高活动版本号(即无需手动标记)?

lad*_*dge 5

GitVersion 的工作原理是

  1. 找到最新的“基础版本”,然后
  2. 找到最重要的增量(即主要、次要、补丁)。

就我而言,基本版本取自最新的标签 2.2.0。我的+semver:patch消息被视为 (2) 的一部分,但默认情况下,开发分支配置为增加次要版本:

branches:
  develop:
    mode: ContinuousDeployment
    tag: alpha
    increment: Minor
Run Code Online (Sandbox Code Playgroud)

默认情况下,GitVersion 不会“堆栈”增量 - 它只是采用单个最重要的增量并将其应用到基本版本。一些相关代码IncrementStrategyFinder是:

// cap the commit message severity to minor for alpha versions
if (baseVersion.SemanticVersion < new SemanticVersion(1) && commitMessageIncrement > VersionField.Minor)
{
    commitMessageIncrement = VersionField.Minor;
}

// don't increment for less than the branch config increment, if the absence of commit messages would have
// still resulted in an increment of configuration.Increment
if (baseVersion.ShouldIncrement && commitMessageIncrement < defaultIncrement)
{
    return defaultIncrement;
}
Run Code Online (Sandbox Code Playgroud)

由于开发分支已经将基本版本增加了一个次要版本(即到 2.3.0),因此我的补丁版本增量指令将被忽略。