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:
@@ -1004,9 +1004,18 @@ async function getAheadOfOrigin(cwd: string, currentBranch: string): Promise<num
|
|||||||
);
|
);
|
||||||
const count = Number.parseInt(stdout.trim(), 10);
|
const count = Number.parseInt(stdout.trim(), 10);
|
||||||
return Number.isNaN(count) ? null : count;
|
return Number.isNaN(count) ? null : count;
|
||||||
|
} catch {
|
||||||
|
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 {
|
} catch {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getBehindOfOrigin(cwd: string, currentBranch: string): Promise<number | null> {
|
async function getBehindOfOrigin(cwd: string, currentBranch: string): Promise<number | null> {
|
||||||
|
|||||||
Reference in New Issue
Block a user