fix(review): pass 1: ahead and diverged labels, diff-scope needs shared history; preflight refreshes origin/<base> and stops on a diff far beyond the PR (GST-462, HARN-15)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
This commit is contained in:
garrytanandcapy-ai[bot] committed 2026-10-31 15:30:22 +00:00
1 parent 0d4846cc0a
commit 86b279fcae
8 files changed
+72 -9

No files matched your search

+3 -2
View File
@@ -94,7 +94,7 @@ export function isShallow(cwd: string): boolean {
* tracking ref is a fix and not a loop. `local` says why the twin won when the
* local branch differs from it.
*/
export function resolveBase(ref: string, cwd: string, head?: string): { ref: string; sha: string; local?: 'missing' | 'unrelated' | 'behind' | 'diverged' } | null {
export function resolveBase(ref: string, cwd: string, head?: string): { ref: string; sha: string; local?: 'missing' | 'unrelated' | 'behind' | 'ahead' | 'diverged' } | null {
const related = (sha: string) => !head || mergeBase(sha, head, cwd) !== null;
const direct = resolvesToCommit(ref, cwd);
if (isBranchName(ref)) {
@@ -103,7 +103,8 @@ export function resolveBase(ref: string, cwd: string, head?: string): { ref: str
const sha = resolvesToCommit(tracking, cwd);
if (!sha || !related(sha)) continue;
if (sha === direct) return { ref, sha };
const local = !direct ? 'missing' : !related(direct) ? 'unrelated' : mergeBase(direct, sha, cwd) === direct ? 'behind' : 'diverged';
const fork = direct && related(direct) ? mergeBase(direct, sha, cwd) : null;
const local = !direct ? 'missing' : !fork ? 'unrelated' : fork === direct ? 'behind' : fork === sha ? 'ahead' : 'diverged';
return { ref: tracking, sha, local };
}
}