Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(version-tools): Fix scheme detection and add more test cases #21710

Merged
merged 2 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build-tools/packages/version-tools/src/semver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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.
Expand Down
16 changes: 16 additions & 0 deletions build-tools/packages/version-tools/src/test/semver.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
});
Expand Down
Loading