Fix ahead-of-origin count for branches with no remote tracking branch

Fall back to counting all local commits when the origin comparison
fails, instead of returning null.
This commit is contained in:
Mohamed Boudra
2026-04-12 14:52:41 +07:00
parent cd4db5d81f
commit ca20945b93
+10 -1
View File
@@ -1005,7 +1005,16 @@ async function getAheadOfOrigin(cwd: string, currentBranch: string): Promise<num
const count = Number.parseInt(stdout.trim(), 10);
return Number.isNaN(count) ? null : count;
} catch {
return null;
try {
const { stdout } = await execAsync(
`git rev-list --count ${currentBranch}`,
{ cwd, env: READ_ONLY_GIT_ENV },
);
const count = Number.parseInt(stdout.trim(), 10);
return Number.isNaN(count) ? null : count;
} catch {
return null;
}
}
}