Fix false unpushed commit warnings for worktree archive (#1158)

* fix(server): avoid false unpushed worktree commits

* fix(server): preserve local-only worktree push counts
This commit is contained in:
Mohamed Boudra
2026-05-24 12:41:36 +08:00
committed by GitHub
parent 94bccf19ba
commit 79dcbdc1c1
2 changed files with 57 additions and 6 deletions
+10 -6
View File
@@ -1268,6 +1268,7 @@ async function getAheadBehind(
async function getAheadOfOrigin(
cwd: string,
currentBranch: string,
baseRef: string | null,
context?: CheckoutContext,
): Promise<number | null> {
if (!currentBranch) {
@@ -1286,12 +1287,15 @@ async function getAheadOfOrigin(
if (trackedOriginBranch) {
return null;
}
if (!baseRef || normalizeLocalBranchRefName(baseRef) === currentBranch) {
return null;
}
try {
const { stdout } = await runGitCommand(["rev-list", "--count", currentBranch], {
cwd,
envOverlay: READ_ONLY_GIT_ENV,
logger: context?.logger,
});
const comparisonBaseRef = await resolveBestComparisonBaseRef(cwd, baseRef, context);
const { stdout } = await runGitCommand(
["rev-list", "--count", `${comparisonBaseRef}..${currentBranch}`],
{ cwd, envOverlay: READ_ONLY_GIT_ENV, logger: context?.logger },
);
const count = Number.parseInt(stdout.trim(), 10);
return Number.isNaN(count) ? null : count;
} catch {
@@ -1503,7 +1507,7 @@ export async function getCheckoutStatus(
? getAheadBehind(cwd, baseRef, currentBranch, context)
: Promise.resolve(null),
hasRemote && currentBranch
? getAheadOfOrigin(cwd, currentBranch, context)
? getAheadOfOrigin(cwd, currentBranch, baseRef, context)
: Promise.resolve(null),
hasRemote && currentBranch
? getBehindOfOrigin(cwd, currentBranch, context)