Skip to content

Commit e42f784

Browse files
devversionjelbourn
authored andcommitted
build: fix release scripts not all parsing versions properly (#17005)
Fixes the release scripts not properly parsing versions in the following scenarios: 1) The version has a pre-release version set to `0`. In that case the version pre-release version will be ignored. 2) The version has a pre-release version higher than `9`. In that case the Regex for parsing the version has an invalid capture group that only matches a single-digit pre-release version.
1 parent 4a5e952 commit e42f784

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

tools/release/version-name/parse-version.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/** Regular expression that matches version names and the individual version segments. */
2-
const versionNameRegex = /^(\d+)\.(\d+)\.(\d+)(?:-(alpha|beta|rc)\.(\d)+)?$/;
2+
const versionNameRegex = /^(\d+)\.(\d+)\.(\d+)(?:-(alpha|beta|rc)\.(\d+))?$/;
33

44
export class Version {
55
constructor(
@@ -44,7 +44,7 @@ export function parseVersionName(version: string): Version|null {
4444

4545
return new Version(
4646
Number(matches[1]), Number(matches[2]), Number(matches[3]), matches[4] || null,
47-
Number(matches[5]) || null);
47+
matches[5] !== undefined ? Number(matches[5]) : null);
4848
}
4949

5050
/** Serializes the specified version into a string. */

0 commit comments

Comments
 (0)