|
1 | 1 | import { |
2 | 2 | DEFAULT_SERVER_SETTINGS, |
3 | 3 | EventId, |
| 4 | + GitManagerError, |
4 | 5 | ProjectId, |
5 | 6 | ProviderInstanceId, |
6 | 7 | ProviderDriverKind, |
@@ -1577,6 +1578,8 @@ describe("storage cleanup", () => { |
1577 | 1578 | "unmerged", |
1578 | 1579 | "unchanged", |
1579 | 1580 | "unchanged-two-worktrees", |
| 1581 | + "unchanged-lookup-failed", |
| 1582 | + "unchanged-other-pr", |
1580 | 1583 | "diverged", |
1581 | 1584 | "head-moved", |
1582 | 1585 | "deleted", |
@@ -1637,15 +1640,18 @@ describe("storage cleanup", () => { |
1637 | 1640 | yield* fs.writeFileString(recentImage, "recent"); |
1638 | 1641 | const recent = DateTime.toDateUtc(DateTime.makeUnsafe(NOW)); |
1639 | 1642 | yield* fs.utimes(recentImage, recent, recent); |
| 1643 | + const linkedUnchanged = |
| 1644 | + protection === "unchanged-lookup-failed" || protection === "unchanged-other-pr"; |
1640 | 1645 | const thread = makeThread("storage-thread", { |
1641 | | - branchPullRequest: protection.startsWith("squash-") |
1642 | | - ? { |
1643 | | - projectId: PROJECT_ID, |
1644 | | - repository: "owner/repo", |
1645 | | - number: 42, |
1646 | | - url: "https://example.test/owner/repo/pull/42", |
1647 | | - } |
1648 | | - : null, |
| 1646 | + branchPullRequest: |
| 1647 | + protection.startsWith("squash-") || linkedUnchanged |
| 1648 | + ? { |
| 1649 | + projectId: PROJECT_ID, |
| 1650 | + repository: "owner/repo", |
| 1651 | + number: 42, |
| 1652 | + url: "https://example.test/owner/repo/pull/42", |
| 1653 | + } |
| 1654 | + : null, |
1649 | 1655 | branch: "feature", |
1650 | 1656 | worktreePath, |
1651 | 1657 | latestUserMessageAt: |
@@ -1679,6 +1685,7 @@ describe("storage cleanup", () => { |
1679 | 1685 | const unchangedRule = |
1680 | 1686 | protection === "unchanged" || |
1681 | 1687 | protection === "unchanged-two-worktrees" || |
| 1688 | + linkedUnchanged || |
1682 | 1689 | protection === "diverged" || |
1683 | 1690 | protection === "head-moved"; |
1684 | 1691 | let headReads = 0; |
@@ -1831,19 +1838,33 @@ describe("storage cleanup", () => { |
1831 | 1838 | invalidateStatus: () => Effect.void, |
1832 | 1839 | branchPullRequest: (input, options) => { |
1833 | 1840 | assert.strictEqual(options?.refresh, true); |
1834 | | - if (protection.startsWith("squash-")) { |
| 1841 | + if (protection.startsWith("squash-") || linkedUnchanged) { |
1835 | 1842 | assert.strictEqual( |
1836 | 1843 | input.reference, |
1837 | 1844 | "https://example.test/owner/repo/pull/42", |
1838 | 1845 | ); |
1839 | 1846 | } |
| 1847 | + if (protection === "unchanged-lookup-failed") { |
| 1848 | + return Effect.fail( |
| 1849 | + new GitManagerError({ |
| 1850 | + operation: "branchPullRequest", |
| 1851 | + cwd: input.cwd, |
| 1852 | + detail: "host unavailable", |
| 1853 | + }), |
| 1854 | + ); |
| 1855 | + } |
1840 | 1856 | return Effect.succeed({ |
1841 | 1857 | ...makeBranchPullRequest( |
1842 | 1858 | protection === "unmerged" || protection === "squash-stale" |
1843 | 1859 | ? "open" |
1844 | 1860 | : "merged", |
1845 | 1861 | ), |
1846 | | - headRef: protection === "squash-wrong-branch" ? "other" : "feature", |
| 1862 | + headRef: |
| 1863 | + protection === "squash-wrong-branch" || protection === "unchanged-other-pr" |
| 1864 | + ? "other" |
| 1865 | + : "feature", |
| 1866 | + // Cleanup must not measure this checkout against another branch's target. |
| 1867 | + ...(protection === "unchanged-other-pr" ? { baseRef: "release" } : {}), |
1847 | 1868 | url: "https://example.test/owner/repo/pull/42", |
1848 | 1869 | ...(protection.startsWith("squash-") && protection !== "squash-missing-head" |
1849 | 1870 | ? { headSha: (protection === "squash-extra" ? "c" : "a").repeat(40) } |
@@ -2048,7 +2069,8 @@ describe("storage cleanup", () => { |
2048 | 2069 | protection === "merged" || |
2049 | 2070 | protection === "squash-merged" || |
2050 | 2071 | protection === "unchanged" || |
2051 | | - protection === "unchanged-two-worktrees"; |
| 2072 | + protection === "unchanged-two-worktrees" || |
| 2073 | + linkedUnchanged; |
2052 | 2074 | assert.strictEqual(yield* fs.exists(worktreePath), !removed); |
2053 | 2075 | assert.deepStrictEqual( |
2054 | 2076 | removals, |
|
0 commit comments