Skip to content

Commit 0f63700

Browse files
Add tag name option
1 parent 274a42e commit 0f63700

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

src/NerdBank.GitVersioning/VersionOptions.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ public class VersionOptions : IEquatable<VersionOptions>
4646
/// </summary>
4747
private const int DefaultSemVer1NumericIdentifierPadding = 4;
4848

49+
/// <summary>
50+
/// The default value for the <see cref="TagName"/> property.
51+
/// </summary>
52+
private const string DefaultTagName = "v{version}";
53+
4954
/// <summary>
5055
/// A value indicating whether mutations of this instance are not allowed.
5156
/// </summary>
@@ -109,6 +114,12 @@ public class VersionOptions : IEquatable<VersionOptions>
109114
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
110115
private CloudBuildOptions? cloudBuild;
111116

117+
/// <summary>
118+
/// Backing field for the <see cref="TagName"/> property.
119+
/// </summary>
120+
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
121+
private string? tagName;
122+
112123
/// <summary>
113124
/// Backing field for the <see cref="Release"/> property.
114125
/// </summary>
@@ -153,6 +164,7 @@ public VersionOptions(VersionOptions copyFrom)
153164
this.publicReleaseRefSpec = copyFrom.publicReleaseRefSpec?.ToList();
154165
this.cloudBuild = copyFrom.cloudBuild is object ? new CloudBuildOptions(copyFrom.cloudBuild) : null;
155166
this.release = copyFrom.release is object ? new ReleaseOptions(copyFrom.release) : null;
167+
this.tagName = copyFrom.tagName;
156168
this.pathFilters = copyFrom.pathFilters?.ToList();
157169
}
158170

@@ -472,6 +484,22 @@ public ReleaseOptions? Release
472484
[JsonIgnore]
473485
public ReleaseOptions ReleaseOrDefault => this.Release ?? ReleaseOptions.DefaultInstance;
474486

487+
/// <summary>
488+
/// Gets or sets the tag name template for tagging.
489+
/// </summary>
490+
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
491+
public string? TagName
492+
{
493+
get => this.tagName;
494+
set => this.SetIfNotReadOnly(ref this.tagName, value);
495+
}
496+
497+
/// <summary>
498+
/// Gets the tag name template for tagging.
499+
/// </summary>
500+
[JsonIgnore]
501+
public string? TagNameOrDefault => this.TagName ?? DefaultTagName;
502+
475503
/// <summary>
476504
/// Gets or sets a list of paths to use to filter commits when calculating version height.
477505
/// If a given commit does not affect any paths in this filter, it is ignored for version height calculations.

src/NerdBank.GitVersioning/version.schema.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@
176176
"type": "object",
177177
"properties": {
178178
"branchName": {
179-
"description": "Defines the format of release branch names. Format must include a placeholder '{version}' for the version",
179+
"description": "Defines the format of release branch names. Format must include a placeholder '{version}' for the version.",
180180
"type": "string",
181181
"pattern": ".*\\{version\\}.*",
182182
"default": "v{version}"
@@ -188,13 +188,19 @@
188188
"default": "minor"
189189
},
190190
"firstUnstableTag": {
191-
"description": "Specifies the first/default prerelease tag for new versions",
191+
"description": "Specifies the first/default prerelease tag for new versions.",
192192
"type": "string",
193193
"default": "alpha"
194194
}
195195
},
196196
"additionalProperties": false
197197
},
198+
"tagName": {
199+
"description": "Defines the format of tag names. Format must include a placeholder '{version}' for the version.",
200+
"type": "string",
201+
"pattern": ".*\\{version\\}.*",
202+
"default": "v{version}"
203+
},
198204
"pathFilters": {
199205
"type": "array",
200206
"description": "An array of pathspec-like strings that are used to filter commits when calculating the version height. A commit will not increment the version height if its changed files are not included by these filters.\nPaths are relative to this file. Paths relative to the root of the repository can be specified with the `:/` prefix.\nExclusions can be specified with a `:^` prefix for relative paths, or a `:^/` prefix for paths relative to the root of the repository.\nAfter a path matches any non-exclude filter, it will be run through all exclude filters. If it matches, the path is ignored.",

0 commit comments

Comments
 (0)