mirror of https://github.com/garrytan/gstack.git
feat: add {{BASE_BRANCH_DETECT}} resolver to gen-skill-docs
DRY placeholder for dynamic base branch detection across PR-targeting skills. Detects via gh pr view (existing PR base) → gh repo view (repo default) → fallback to main. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
bb46ca6b21
commit
ad6f91d00c
|
|
@ -126,11 +126,33 @@ If \`NEEDS_SETUP\`:
|
||||||
3. If \`bun\` is not installed: \`curl -fsSL https://bun.sh/install | bash\``;
|
3. If \`bun\` is not installed: \`curl -fsSL https://bun.sh/install | bash\``;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function generateBaseBranchDetect(): string {
|
||||||
|
return `## Step 0: Detect base branch
|
||||||
|
|
||||||
|
Determine which branch this PR targets. Use the result as "the base branch" in all subsequent steps.
|
||||||
|
|
||||||
|
1. Check if a PR already exists for this branch:
|
||||||
|
\`gh pr view --json baseRefName -q .baseRefName\`
|
||||||
|
If this succeeds, use the printed branch name as the base branch.
|
||||||
|
|
||||||
|
2. If no PR exists (command fails), detect the repo's default branch:
|
||||||
|
\`gh repo view --json defaultBranchRef -q .defaultBranchRef.name\`
|
||||||
|
|
||||||
|
3. If both commands fail, fall back to \`main\`.
|
||||||
|
|
||||||
|
Print the detected base branch name. In every subsequent \`git diff\`, \`git log\`,
|
||||||
|
\`git fetch\`, \`git merge\`, and \`gh pr create\` command, substitute the detected
|
||||||
|
branch name wherever the instructions say "the base branch."
|
||||||
|
|
||||||
|
---`;
|
||||||
|
}
|
||||||
|
|
||||||
const RESOLVERS: Record<string, () => string> = {
|
const RESOLVERS: Record<string, () => string> = {
|
||||||
COMMAND_REFERENCE: generateCommandReference,
|
COMMAND_REFERENCE: generateCommandReference,
|
||||||
SNAPSHOT_FLAGS: generateSnapshotFlags,
|
SNAPSHOT_FLAGS: generateSnapshotFlags,
|
||||||
UPDATE_CHECK: generateUpdateCheck,
|
UPDATE_CHECK: generateUpdateCheck,
|
||||||
BROWSE_SETUP: generateBrowseSetup,
|
BROWSE_SETUP: generateBrowseSetup,
|
||||||
|
BASE_BRANCH_DETECT: generateBaseBranchDetect,
|
||||||
};
|
};
|
||||||
|
|
||||||
// ─── Template Processing ────────────────────────────────────
|
// ─── Template Processing ────────────────────────────────────
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue