Fix auto-archive after merged PR branch deletion (#1378)
This commit is contained in:
@@ -233,15 +233,15 @@ describe("archiveIfSafe", () => {
|
|||||||
expect(harness.deps.archivePaseoWorktree).not.toHaveBeenCalled();
|
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({
|
const harness = createHarness({
|
||||||
getSnapshot: async () => createSnapshot({ git: { aheadOfOrigin: null } }),
|
getSnapshot: async () =>
|
||||||
|
createSnapshot({ git: { aheadOfOrigin: null, behindOfOrigin: null } }),
|
||||||
});
|
});
|
||||||
|
|
||||||
await runArchiveIfSafe(harness);
|
await runArchiveIfSafe(harness);
|
||||||
|
|
||||||
expect(harness.deps.isPaseoOwnedWorktreeCwd).not.toHaveBeenCalled();
|
expect(harness.deps.archivePaseoWorktree).toHaveBeenCalledTimes(1);
|
||||||
expect(harness.deps.archivePaseoWorktree).not.toHaveBeenCalled();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test("does nothing when the cwd is not a Paseo-owned worktree", async () => {
|
test("does nothing when the cwd is not a Paseo-owned worktree", async () => {
|
||||||
|
|||||||
@@ -78,10 +78,10 @@ export async function archiveIfSafe(input: {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (snapshot.git.isDirty === true || snapshot.git.aheadOfOrigin === null) {
|
if (snapshot.git.isDirty === true) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (snapshot.git.aheadOfOrigin > 0) {
|
if (typeof snapshot.git.aheadOfOrigin === "number" && snapshot.git.aheadOfOrigin > 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user