Skip to content

Commit 57a57f6

Browse files
authored
resolving patch version conflict (#11707)
1 parent 69dcaa5 commit 57a57f6

File tree

5 files changed

+19
-13
lines changed

5 files changed

+19
-13
lines changed

Tasks/UseDotNetV2/models.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,13 @@ export class VersionParts {
121121
try {
122122
let parts = version.split('.');
123123
// validate version
124-
if ((parts.length != 3) || // check if the version has 3 parts
124+
if ((parts.length < 3) || // check if the version has at least 3 parts
125125
!parts[0] || // The major version must always be set
126126
!parts[1] || // The minor version must always be set
127127
!parts[2] || // The patch version must always be set
128128
Number.isNaN(Number.parseInt(parts[0])) || // the major version number must be a number
129129
Number.isNaN(Number.parseInt(parts[1])) || // the minor version number must be a number
130-
Number.isNaN(Number.parseInt(parts[2].split('-')[0])) // the patch version number must be a number. (the patch version can have a '-' because of version numbers like: 1.0.0-beta-50)
130+
Number.isNaN(Number.parseInt(parts[2].split(/\-|\+/)[0])) // the patch version number must be a number. (the patch version can have a '-', or a '+' because of version numbers like: 1.0.0-beta-50)
131131
) {
132132
throw tl.loc("OnlyExplicitVersionAllowed", version);
133133
}
@@ -149,16 +149,22 @@ export class VersionParts {
149149
try {
150150
let parts = version.split('.');
151151
// validate version
152-
if ((parts.length < 2 || parts.length > 3) || // check if the version has 2 or 3 parts
152+
if (parts.length < 2 || // check if the version has at least 3 parts
153153
(parts[1] == "x" && parts.length > 2) || // a version number like `1.x` must have only major and minor version
154154
(parts[1] != "x" && parts.length <= 2) || // a version number like `1.1` must have a patch version
155155
!parts[0] || // The major version must always be set
156156
!parts[1] || // The minor version must always be set
157157
(parts.length == 3 && !parts[2]) || // a version number like `1.1.` is invalid because the patch version is missing
158158
Number.isNaN(Number.parseInt(parts[0])) || // the major version number must be a number
159-
( // The next lines check the minor version
160-
Number.isNaN(Number.parseInt(parts[1])) && // the minor version number must be a number
161-
parts[1] != "x" // the minor version can't be `x`
159+
(
160+
parts[1] != "x" && // if the minor version is not `x`
161+
(
162+
Number.isNaN(Number.parseInt(parts[1])) || // the minor version number must be a number
163+
(
164+
parts.length > 2 && parts[2] != "x" && // if the patch is not `x`, then its an explicit version
165+
!semver.valid(version) // validate the explicit version
166+
)
167+
)
162168
)
163169
) {
164170
throw tl.loc("VersionNumberHasTheWrongFormat", version);
@@ -178,4 +184,4 @@ export class VersionParts {
178184
* the version number entered by the user
179185
*/
180186
public versionSpec: string;
181-
}
187+
}

Tasks/UseDotNetV2/package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Tasks/UseDotNetV2/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"azure-pipelines-task-lib": "3.0.0-preview",
3030
"azure-pipelines-tool-lib": "0.11.0",
3131
"packaging-common": "file:../../_build/Tasks/Common/packaging-common-1.0.1.tgz",
32-
"semver": "6.0.0",
32+
"semver": "6.3.0",
3333
"typed-rest-client": "0.11.0",
3434
"utility-common-v2": "file:../../_build/Tasks/Common/utility-common-v2-2.0.0.tgz"
3535
}

Tasks/UseDotNetV2/task.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"version": {
1515
"Major": 2,
1616
"Minor": 0,
17-
"Patch": 21
17+
"Patch": 22
1818
},
1919
"satisfies": [
2020
"DotNetCore"

Tasks/UseDotNetV2/task.loc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"version": {
1515
"Major": 2,
1616
"Minor": 0,
17-
"Patch": 21
17+
"Patch": 22
1818
},
1919
"satisfies": [
2020
"DotNetCore"

0 commit comments

Comments
 (0)