Skip to content

Commit 1d2ff0f

Browse files
committed
fix(AI-81): fail fast when merge-base cannot be computed
Without an explicit guard, `git merge-base <base> HEAD` failing (unrelated histories or shallow clones) leaves `MERGE_BASE` empty, and the subsequent `git diff "..HEAD"` becomes `HEAD..HEAD` — an empty diff that would silently produce zero chapters. Tell the agent to abort with a clear error before continuing.
1 parent 11b7833 commit 1d2ff0f

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

skills/stage-chapters/SKILL.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ HEAD_SHA=$(git rev-parse HEAD)
5959
git diff "$MERGE_BASE..HEAD"
6060
```
6161

62+
If `git merge-base` exits non-zero or `MERGE_BASE` is empty, stop with an error like `Could not compute merge-base between <base> and HEAD (unrelated histories or shallow clone).` Do **not** continue — running `git diff "..HEAD"` with an empty `MERGE_BASE` produces an empty diff that would silently yield zero chapters.
63+
6264
`git diff <merge-base>..HEAD` covers exactly the commits on the branch since it diverged from the base — the same range the SPA renders for a `committed` run (`baseSha..headSha` in `packages/cli/src/routes/diff.ts`). Save the full diff text into context for Step 3.
6365

6466
This skill scopes review to *committed* work. If the user has uncommitted changes to tracked files, instruct them to commit first; mixing committed and working-tree changes into a single run would produce `hunkRefs`/`lineRefs` that don't line up with the diff the SPA serves.

0 commit comments

Comments
 (0)