diff --git a/bin/gstack-next-version b/bin/gstack-next-version index 1df13aad8e..dbb7229eed 100755 --- a/bin/gstack-next-version +++ b/bin/gstack-next-version @@ -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 @@ -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. diff --git a/test/gstack-next-version.test.ts b/test/gstack-next-version.test.ts index 9099fd626e..0759889b1e 100644 --- a/test/gstack-next-version.test.ts +++ b/test/gstack-next-version.test.ts @@ -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, @@ -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]);