mirror of
https://github.com/garrytan/gstack.git
synced 2026-09-13 16:38:56 +02:00
fix(bins): detect the default branch instead of hardcoding main
gstack-diff-scope fell to an empty diff (all-false SCOPE_*) and gstack-next-version mis-based its bump math on any repo whose default branch isn't main (trunk, master, local-only). Both now resolve origin/HEAD -> origin/main -> origin/master -> main. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
b81d72d059
commit
56d83c684c
+10
-1
@@ -405,7 +405,16 @@ function parseArgs(argv: string[]): { base: string; bump: Bump; current: string;
|
||||
else if (a === "-h" || a === "--help") help = true;
|
||||
}
|
||||
if (help) return { base: "", bump: "micro", current: "", excludePR: null, help: true };
|
||||
if (!base) base = "main";
|
||||
if (!base) {
|
||||
// Detect the default branch instead of assuming main (local-only repos
|
||||
// on trunk/master work like GitHub repos on main).
|
||||
try {
|
||||
const head = execFileSync("git", ["symbolic-ref", "refs/remotes/origin/HEAD"], { encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"] }).trim();
|
||||
base = head.replace("refs/remotes/origin/", "") || "main";
|
||||
} catch {
|
||||
base = "main";
|
||||
}
|
||||
}
|
||||
if (!bump) {
|
||||
console.error("Error: --bump is required (major|minor|patch|micro)");
|
||||
process.exit(2);
|
||||
|
||||
Reference in New Issue
Block a user