Skip to content

Commit de09f32

Browse files
authored
Merge pull request #1293 from dotnet/copilot/update-version-schema-regex
Allow uppercase letters in pre-release version identifiers
2 parents 44c7f5b + 14c2611 commit de09f32

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

src/NerdBank.GitVersioning/version.schema.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"version": {
3232
"type": "string",
3333
"description": "The major.minor-pre version to use as the basis for version calculations. If {height} is not used in this value and the value has fewer than the full major.minor.build.revision specified, \".{height}\" will be appended by the build.",
34-
"pattern": "^v?(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)(?:\\.(0|[1-9][0-9]*)(?:\\.(0|[1-9][0-9]*))?)?(-(?:[\\da-z\\-]+|\\{height\\})(?:\\.(?:[\\da-z\\-]+|\\{height\\}))*)?(\\+(?:[\\da-z\\-]+|\\{height\\})(?:\\.(?:[\\da-z\\-]+|\\{height\\}))*)?$"
34+
"pattern": "^v?(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)(?:\\.(0|[1-9][0-9]*)(?:\\.(0|[1-9][0-9]*))?)?(-(?:[\\da-zA-Z\\-]+|\\{height\\})(?:\\.(?:[\\da-zA-Z\\-]+|\\{height\\}))*)?(\\+(?:[\\da-zA-Z\\-]+|\\{height\\})(?:\\.(?:[\\da-zA-Z\\-]+|\\{height\\}))*)?$"
3535
},
3636
"inherit": {
3737
"type": "boolean",
@@ -71,7 +71,7 @@
7171
"versionHeightOffsetAppliesTo": {
7272
"type": "string",
7373
"description": "The version to which the versionHeightOffset applies. When the version property changes such that the version height would be reset, and this property does not match the new version, the versionHeightOffset will be ignored. This allows the offset to implicitly reset as intended without having to manually remove it from all version.json files.",
74-
"pattern": "^v?(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)(?:\\.(0|[1-9][0-9]*)(?:\\.(0|[1-9][0-9]*))?)?(-(?:[\\da-z\\-]+|\\{height\\})(?:\\.(?:[\\da-z\\-]+|\\{height\\}))*)?(\\+(?:[\\da-z\\-]+|\\{height\\})(?:\\.(?:[\\da-z\\-]+|\\{height\\}))*)?$"
74+
"pattern": "^v?(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)(?:\\.(0|[1-9][0-9]*)(?:\\.(0|[1-9][0-9]*))?)?(-(?:[\\da-zA-Z\\-]+|\\{height\\})(?:\\.(?:[\\da-zA-Z\\-]+|\\{height\\}))*)?(\\+(?:[\\da-zA-Z\\-]+|\\{height\\})(?:\\.(?:[\\da-zA-Z\\-]+|\\{height\\}))*)?$"
7575
},
7676
"buildNumberOffset": {
7777
"type": "integer",
@@ -94,7 +94,7 @@
9494
"gitCommitIdPrefix": {
9595
"type": "string",
9696
"description": "The git commit prefix (e.g. 'g') in non-public release versions.",
97-
"pattern": "^[^0-9][\\da-z\\-_\\.]*$",
97+
"pattern": "^[^0-9][\\da-zA-Z\\-_\\.]*$",
9898
"default": "g"
9999
},
100100
"gitCommitIdShortAutoMinimum": {

test/Nerdbank.GitVersioning.Tests/VersionSchemaTests.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,4 +112,28 @@ public void ReleaseProperty_InvalidJson(string json)
112112
this.json = JObject.Parse(json);
113113
Assert.False(this.json.IsValid(this.schema));
114114
}
115+
116+
[Fact]
117+
public void VersionField_SupportsUppercaseLettersInPreRelease()
118+
{
119+
// Test uppercase letters in pre-release identifiers
120+
this.json = JObject.Parse(@"{ ""version"": ""2.3-BETA"" }");
121+
Assert.True(this.json.IsValid(this.schema));
122+
this.json = JObject.Parse(@"{ ""version"": ""2.3-Beta"" }");
123+
Assert.True(this.json.IsValid(this.schema));
124+
this.json = JObject.Parse(@"{ ""version"": ""2.3-RC"" }");
125+
Assert.True(this.json.IsValid(this.schema));
126+
this.json = JObject.Parse(@"{ ""version"": ""2.3-Alpha.1"" }");
127+
Assert.True(this.json.IsValid(this.schema));
128+
this.json = JObject.Parse(@"{ ""version"": ""2.3-BETA-Final"" }");
129+
Assert.True(this.json.IsValid(this.schema));
130+
this.json = JObject.Parse(@"{ ""version"": ""1.2.3-RC1"" }");
131+
Assert.True(this.json.IsValid(this.schema));
132+
133+
// Test uppercase in build metadata
134+
this.json = JObject.Parse(@"{ ""version"": ""2.3+BUILD"" }");
135+
Assert.True(this.json.IsValid(this.schema));
136+
this.json = JObject.Parse(@"{ ""version"": ""2.3-beta+BUILD.123"" }");
137+
Assert.True(this.json.IsValid(this.schema));
138+
}
115139
}

0 commit comments

Comments
 (0)