Fix ahead count when upstream branch is gone (#1023)

This commit is contained in:
Mohamed Boudra
2026-05-14 19:10:14 +08:00
committed by GitHub
parent 2dd77aae04
commit faa0d93cb8
2 changed files with 32 additions and 1 deletions
@@ -378,6 +378,22 @@ const x = 1;
expect(divergedStatus.behindOfOrigin).toBe(1);
});
it("does not report the full branch history as ahead when the current branch remote is gone", async () => {
setupRemoteTrackingMain(repoDir, tempDir);
execFileSync("git", ["checkout", "-b", "feature"], { cwd: repoDir });
commitFile(repoDir, "feature.txt", "feature\n", "feature commit");
execFileSync("git", ["push", "-u", "origin", "feature"], { cwd: repoDir });
execFileSync("git", ["push", "origin", "--delete", "feature"], { cwd: repoDir });
execFileSync("git", ["fetch", "--prune", "origin"], { cwd: repoDir });
const status = await getCheckoutStatus(repoDir);
expect(status.isGit).toBe(true);
if (!status.isGit) {
return;
}
expect(status.aheadOfOrigin).toBeNull();
});
it("does not report incoming additions when the base branch is behind its remote", async () => {
const { cloneDir } = setupRemoteTrackingMain(repoDir, tempDir);
commitFile(cloneDir, "file.txt", "remote one\nremote two\n", "remote update");