Skip to content

Commit 6653b18

Browse files
committed
fix(AI-81): keep full origin/HEAD ref so base works in single-branch clones
Previously the skill stripped `origin/` from `origin/main`, leaving `<base>` set to `main`. In single-branch clones (and after deleting a local `main`) that local ref does not exist, so the subsequent `git merge-base <base> HEAD` and `git rev-parse <base>` calls fail. Use the full remote-tracking ref (`origin/main`) as `<base>` directly — git accepts it everywhere a commit-ish is expected.
1 parent a14ab7b commit 6653b18

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

skills/stage-chapters/SKILL.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,19 @@ Run these checks before any other work. If either fails, stop with the error mes
3232

3333
## Step 1 — Detect base ref
3434

35-
Find the branch the user reviews against. Try each of the following in order; use the first that succeeds:
35+
Find the branch the user reviews against. Try each of the following in order; the first that succeeds becomes `<base>`:
3636

37-
1. `git rev-parse --abbrev-ref origin/HEAD 2>/dev/null` — typically resolves to `origin/main` (exits non-zero when `origin/HEAD` is unset). Strip the leading `origin/` to recover the bare base name.
38-
2. `git rev-parse --verify main 2>/dev/null`fall back to a local `main` branch.
39-
3. `git rev-parse --verify master 2>/dev/null`final fallback for older repos.
37+
1. `git rev-parse --abbrev-ref origin/HEAD 2>/dev/null` — typically prints `origin/main`. Use the full output (e.g. `origin/main`) as `<base>`; do **not** strip `origin/`, because the bare name (`main`) may not exist locally in single-branch clones.
38+
2. `git rev-parse --verify main 2>/dev/null`local `main` branch; use `main` as `<base>`.
39+
3. `git rev-parse --verify master 2>/dev/null`older repos; use `master` as `<base>`.
4040

4141
If all three fail, stop with:
4242

4343
```
4444
No default branch detected. Tried origin/HEAD, main, and master.
4545
```
4646

47-
Save the resolved base name (e.g. `main`) as `<base>` for the next steps.
47+
`<base>` is whatever ref expression was verified above (`origin/main`, `main`, or `master`) and is passed verbatim to `git merge-base` / `git rev-parse` in Step 2.
4848

4949
## Step 2 — Get the diff
5050

0 commit comments

Comments
 (0)