You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
getMergeBase lacks explanation on how to fix it when it fails #212
Hi @JuanGalilea, thanks for splitting this out. I'd like to pick it up. I can base it on git-diff / refactor/cosmetic-change, or wait until that lands, whichever you prefer.
I reproduced the failure modes with a shallow checkout. git merge-base <target> HEAD fails in three distinct ways, and two of them have the same exit code:
Case
Exit code
stderr
What the user should do
Target ref not fetched (e.g. --single-branch / default PR checkout)
128
Not a valid object name origin/master
fetch the target branch, or use fetch-depth: 0
Shallow history, fork point not fetched
1
(empty)
fetch-depth: 0 in actions/checkout (or git fetch --deepen=<n> / --unshallow)
Cases 2 and 3 look the same from git's side, so today the user only gets Git error: with an empty message. My proposal:
Catch GitCommandError in getMergeBase and branch on the cause:
exit 128 → "target ref <ref> is not in the local repository" + fetch hint
exit 1 → run git rev-parse --is-shallow-repository. If true, show the shallow-checkout message with the fetch-depth: 0 hint. Otherwise show the "no common ancestor, check --target-branch" message.
Keep the wording consistent with the existing messages in resolveReleaseBaseCommit (same fetch-depth: 0 phrasing).
Add unit tests for all three branches by mocking runGitCommand, similar to the existing merge-base tests in git.test.ts.
Add a short bullet to the README near the existing fetch-depth: 0 note, so the error message and the docs say the same thing.
I'd deliberately not auto-deepen or unshallow on failure. It hides a misconfigured checkout, adds a network round-trip with unbounded depth, and behaves differently across CIs. A clear, actionable error seems better. Happy to change that if you see it differently.
Activity
ilker-ekin commentedon Oct 20, 2026
Hi @JuanGalilea, thanks for splitting this out. I'd like to pick it up. I can base it on
git-diff/refactor/cosmetic-change, or wait until that lands, whichever you prefer.I reproduced the failure modes with a shallow checkout.
git merge-base <target> HEADfails in three distinct ways, and two of them have the same exit code:--single-branch/ default PR checkout)Not a valid object name origin/masterfetch-depth: 0fetch-depth: 0inactions/checkout(orgit fetch --deepen=<n>/--unshallow)--target-branchCases 2 and 3 look the same from git's side, so today the user only gets
Git error:with an empty message. My proposal:GitCommandErroringetMergeBaseand branch on the cause:<ref>is not in the local repository" + fetch hintgit rev-parse --is-shallow-repository. Iftrue, show the shallow-checkout message with thefetch-depth: 0hint. Otherwise show the "no common ancestor, check--target-branch" message.resolveReleaseBaseCommit(samefetch-depth: 0phrasing).runGitCommand, similar to the existingmerge-basetests ingit.test.ts.fetch-depth: 0note, so the error message and the docs say the same thing.I'd deliberately not auto-deepen or unshallow on failure. It hides a misconfigured checkout, adds a network round-trip with unbounded depth, and behaves differently across CIs. A clear, actionable error seems better. Happy to change that if you see it differently.
Does this match what you had in mind?
JuanGalilea commentedon Oct 20, 2026
you can wait if you want, but i ended up closing the git-diff ones in favor of #204 btw.
metalwarrior665 commentedon Oct 26, 2026
#204 is merged so feel free to address this