diff --git a/build-tools/packages/version-tools/src/semver.ts b/build-tools/packages/version-tools/src/semver.ts index 5aa7f26a026d..ecf10f23fb92 100644 --- a/build-tools/packages/version-tools/src/semver.ts +++ b/build-tools/packages/version-tools/src/semver.ts @@ -102,6 +102,7 @@ export function detectBumpType( if (v2Parsed === null || v2 === null) { throw new Error(`Invalid version: ${v2}`); } + const v2Scheme = detectVersionScheme(v2Parsed); const v1IsInternal = isInternalVersionScheme(v1, true, true); const v2IsInternal = isInternalVersionScheme(v2, true, true); @@ -121,7 +122,6 @@ export function detectBumpType( v2PrereleaseId = prereleaseId; } - const v2Scheme = detectVersionScheme(v2Parsed); if ( // This is a special case for RC and internal builds. RC builds are always a // major bump compared to an internal build. diff --git a/build-tools/packages/version-tools/src/test/semver.test.ts b/build-tools/packages/version-tools/src/test/semver.test.ts index c8482a6ad21e..80716152437a 100644 --- a/build-tools/packages/version-tools/src/test/semver.test.ts +++ b/build-tools/packages/version-tools/src/test/semver.test.ts @@ -26,6 +26,22 @@ describe("semver", () => { assert.equal(detectBumpType("0.0.1", "0.0.2"), "patch"); }); + it("RC patch", () => { + assert.equal(detectBumpType("2.0.0-rc.5.0.2", "2.0.0-rc.5.0.3"), "patch"); + }); + + it("internal version scheme patch", () => { + assert.equal(detectBumpType("2.0.0-internal.4.0.7", "2.0.0-internal.4.0.8"), "patch"); + }); + + it("internal -> RC is major", () => { + assert.equal(detectBumpType("2.0.0-internal.1.0.7", "2.0.0-rc.2.0.8"), "major"); + }); + + it("RC -> internal throws", () => { + assert.throws(() => detectBumpType("2.0.0-rc.4.0.7", "2.0.0-internal.5.0.0")); + }); + it("premajor", () => { assert.equal(detectBumpType("0.0.1-foo", "1.0.0"), "major"); });