Skip to content
Open
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
7 changes: 4 additions & 3 deletions bin/gstack-next-version
Original file line number Diff line number Diff line change
Expand Up @@ -446,11 +446,12 @@ function parseArgs(argv: string[]): { base: string; bump: Bump; current: string;
console.error("Error: --bump is required (major|minor|patch|micro)");
process.exit(2);
}
if (!["major", "minor", "patch", "micro"].includes(bump)) {
const normalizedBump = bump.toLowerCase();
if (!["major", "minor", "patch", "micro"].includes(normalizedBump)) {
console.error(`Error: --bump must be major|minor|patch|micro (got ${bump})`);
process.exit(2);
}
return { base, bump: bump as Bump, current, workspaceRoot, excludePR, versionPath, help: false };
return { base, bump: normalizedBump as Bump, current, workspaceRoot, excludePR, versionPath, help: false };
}

// Auto-detect: if --exclude-pr wasn't passed, check whether the current branch
Expand Down Expand Up @@ -785,7 +786,7 @@ async function main() {
// Pure-function exports for testing. The version primitives are re-exported
// from lib/version-source so existing importers of this module keep working
// unchanged.
export { parseVersion, fmtVersion, bumpVersion, cmpVersion, versionWidth, extractVersion };
export { parseArgs, parseVersion, fmtVersion, bumpVersion, cmpVersion, versionWidth, extractVersion };
export { pickNextSlot, markActiveSiblings, resolveVersionPath, fetchGitClaimed };

// Only run main() when invoked as a script, not when imported by tests.
Expand Down
10 changes: 10 additions & 0 deletions test/gstack-next-version.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { chmodSync, mkdirSync, mkdtempSync, readFileSync, writeFileSync, rmSync
import { tmpdir } from "node:os";
import { join } from "node:path";
import {
parseArgs,
parseVersion,
fmtVersion,
bumpVersion,
Expand All @@ -21,6 +22,15 @@ import {
fetchGitClaimed,
} from "../bin/gstack-next-version";

describe("parseArgs case normalization (#2770)", () => {
test("accepts uppercase and mixed-case bump levels", () => {
expect(parseArgs(["--base", "main", "--bump", "MICRO"]).bump).toBe("micro");
expect(parseArgs(["--base", "main", "--bump", "PATCH"]).bump).toBe("patch");
expect(parseArgs(["--base", "main", "--bump", "Minor"]).bump).toBe("minor");
expect(parseArgs(["--base", "main", "--bump", "MAJOR"]).bump).toBe("major");
});
});

describe("parseVersion", () => {
test("accepts 4-digit semver", () => {
expect(parseVersion("1.6.3.0")).toEqual([1, 6, 3, 0]);
Expand Down
Loading