我最近升级到了 GitVersion 6.0.x(由于各种其他问题),现在我似乎无法让我的主版本正确进行版本控制。我希望主构建被命名为“-alpha”,并且只有任何标记的构建才能获得
next-version
字段的确切版本。
这是我的
gitversion.yml
:
# current development version which is first version of next release branched away from master
next-version: 6.4.0
# configuration for all branches
tag-prefix: '[vV]?'
assembly-versioning-scheme: MajorMinorPatchTag
assembly-file-versioning-scheme: MajorMinorPatchTag
mode: ContinuousDelivery
commit-message-incrementing: Enabled
branches:
master:
label: '-alpha'
regex: ^master$|^main$
is-main-branch: true
feature:
mode: ContinuousDelivery
regex: ^workitems?[/-](?<BranchName>.+)
label: '--w.{BranchName}'
source-branches: ['master']
pre-release-weight: 0
pull-request:
regex: (pull|pull\-requests|pr)[/-]
label: -pr
source-branches: ['master']
# Official product releases
release:
regex: releases/[Vv]
label: beta
# Increment patch version after a release
increment: Patch
source-branches: ['master']
如果我在功能分支上,一切似乎都正常,但是当我在主分支上时,这就是输出:
{
"AssemblySemFileVer": "6.4.0.48990",
"AssemblySemVer": "6.4.0.48990",
"BranchName": "master",
"BuildMetaData": null,
"CommitDate": "2024-11-05",
"CommitsSinceVersionSource": 48990,
"EscapedBranchName": "master",
"FullBuildMetaData": "Branch.master.Sha.3edf09c0a1683a97b79b2380bXXXX",
"FullSemVer": "6.4.0-48990",
"InformationalVersion": "6.4.0-48990+Branch.master.Sha.3edf09c0a1683a97b79b2380b5XXX",
"Major": 6,
"MajorMinorPatch": "6.4.0",
"Minor": 4,
"Patch": 0,
"PreReleaseLabel": "",
"PreReleaseLabelWithDash": "",
"PreReleaseNumber": 48990,
"PreReleaseTag": "48990",
"PreReleaseTagWithDash": "-48990",
"SemVer": "6.4.0-48990",
"Sha": "3edf09c0a1683a97b79b2380b5cdacXXXXXX",
"ShortSha": "3edf09c",
"UncommittedChanges": 1,
"VersionSourceSha": "",
"WeightedPreReleaseNumber": 103990
}
使用 5.X 版本的 gitversion ,输出如下:
"Major":6,
"Minor":4,
"Patch":0,
"PreReleaseTag":"alpha.13161",
"PreReleaseTagWithDash":"-alpha.13161",
"PreReleaseLabel":"alpha",
"PreReleaseNumber":13161,
"WeightedPreReleaseNumber":68161,
"BuildMetaData":"",
"BuildMetaDataPadded":"",
"FullBuildMetaData":"Branch.master.Sha.2acac930ea679651600c0ab55cXXXXXXX",
"MajorMinorPatch":"6.4.0",
"SemVer":"6.4.0-alpha.13161",
"LegacySemVer":"6.4.0-alpha13161",
"LegacySemVerPadded":"6.4.0-alpha0013161",
"AssemblySemVer":"6.4.0.13161",
"AssemblySemFileVer":"6.4.0.13161",
"FullSemVer":"6.4.0-alpha.13161",
"InformationalVersion":"6.4.0-alpha.13161+Branch.master.Sha.2acac930ea679651600c0ab55c5XXXXXXXX",
"BranchName":"master",
"Sha":"2acac930ea679651600c0ab55c53bXXXXXXXXXX",
"ShortSha":"2acac93",
"NuGetVersionV2":"6.4.0-alpha0013161",
"NuGetVersion":"6.4.0-alpha0013161",
"NuGetPreReleaseTagV2":"alpha13161",
"NuGetPreReleaseTag":"alpha13161",
"VersionSourceSha":"16f71543433b202773b49d6d5a7dbXXXXXXXXX",
"CommitsSinceVersionSource":13161,
"CommitsSinceVersionSourcePadded":"0013161",
"CommitDate":"2024-10-24"
旧yml文件的相关部分:
# current development version which is first version of next release branched away from master
next-version: 6.4.0
# configuration for all branches
assembly-versioning-scheme: MajorMinorPatchTag
assembly-file-versioning-scheme: MajorMinorPatchTag
mode: ContinuousDeployment
legacy-semver-padding: 7
build-metadata-padding: 7
commits-since-version-source-padding: 7
commit-message-incrementing: Disabled
branches:
master:
regex: ^master$|^main$
tag: alpha
feature:
regex: workitems?[/-]
tag: --w.{BranchName}
source-branches: ['master']
如何让 gitversion 6.0.X 对 master 分支执行与之前版本相同的操作?即
PreRelaseLabel
似乎始终为空。
我发现了问题。运行
gitversion /showconfig
时,可以看到配置中包含默认的 main
分支,该分支优先于手动定义的 master
分支。因此,主分支的设置从未应用。将 yml 更改为
branches:
main:
label: 'alpha'
regex: ^master$|^main$
is-main-branch: true
解决了问题。