Fix auto-archive after merged PR branch deletion (#1378)

This commit is contained in:
Mohamed Boudra
2026-06-06 21:13:16 +08:00
committed by GitHub
parent 2822c02543
commit 0cf1717e04
2 changed files with 6 additions and 6 deletions
@@ -233,15 +233,15 @@ describe("archiveIfSafe", () => {
expect(harness.deps.archivePaseoWorktree).not.toHaveBeenCalled();
});
test("does nothing when the upstream status is unknown", async () => {
test("archives when the PR is merged and the upstream branch was deleted", async () => {
const harness = createHarness({
getSnapshot: async () => createSnapshot({ git: { aheadOfOrigin: null } }),
getSnapshot: async () =>
createSnapshot({ git: { aheadOfOrigin: null, behindOfOrigin: null } }),
});
await runArchiveIfSafe(harness);
expect(harness.deps.isPaseoOwnedWorktreeCwd).not.toHaveBeenCalled();
expect(harness.deps.archivePaseoWorktree).not.toHaveBeenCalled();
expect(harness.deps.archivePaseoWorktree).toHaveBeenCalledTimes(1);
});
test("does nothing when the cwd is not a Paseo-owned worktree", async () => {
@@ -78,10 +78,10 @@ export async function archiveIfSafe(input: {
return;
}
if (snapshot.git.isDirty === true || snapshot.git.aheadOfOrigin === null) {
if (snapshot.git.isDirty === true) {
return;
}
if (snapshot.git.aheadOfOrigin > 0) {
if (typeof snapshot.git.aheadOfOrigin === "number" && snapshot.git.aheadOfOrigin > 0) {
return;
}