11import {
22 DEFAULT_SERVER_SETTINGS ,
33 EventId ,
4- GitManagerError ,
4+ GitCommandError ,
55 ProjectId ,
66 ProviderInstanceId ,
77 ProviderDriverKind ,
@@ -1570,13 +1570,17 @@ describe("storage cleanup", () => {
15701570 "recent" ,
15711571 "merged" ,
15721572 "unmerged" ,
1573- "squash-merged " ,
1573+ "squash-exact-head " ,
15741574 "squash-later-commit" ,
1575- "squash-other-head " ,
1576- "squash-other -base" ,
1577- "squash-no -head-sha " ,
1575+ "squash-release-base " ,
1576+ "squash-stack -base" ,
1577+ "squash-missing -head" ,
15781578 "squash-lookup-failed" ,
1579- "squash-unchanged-only" ,
1579+ "squash-different-branch" ,
1580+ "squash-stale-merged" ,
1581+ "squash-closed" ,
1582+ "squash-head-moved" ,
1583+ "unchanged-squash" ,
15801584 "unchanged" ,
15811585 "unchanged-two-worktrees" ,
15821586 "diverged" ,
@@ -1642,6 +1646,31 @@ describe("storage cleanup", () => {
16421646 const thread = makeThread ( "storage-thread" , {
16431647 branch : "feature" ,
16441648 worktreePath,
1649+ pullRequests :
1650+ protection === "squash-stale-merged"
1651+ ? [
1652+ {
1653+ host : "example.test" ,
1654+ repository : "owner/repository" ,
1655+ number : 42 ,
1656+ url : "https://example.test/owner/repository/pull/42" ,
1657+ source : "manual" ,
1658+ linkedAt : NOW ,
1659+ stack : null ,
1660+ snapshot : {
1661+ state : "merged" ,
1662+ title : "Previously merged" ,
1663+ headBranch : "feature" ,
1664+ baseBranch : "main" ,
1665+ isDraft : false ,
1666+ updatedAt : NOW ,
1667+ syncedAt : NOW ,
1668+ mergedAt : NOW ,
1669+ closedAt : null ,
1670+ } ,
1671+ } ,
1672+ ]
1673+ : [ ] ,
16451674 latestUserMessageAt :
16461675 protection === "recent" ? "2026-08-26T00:00:00.000Z" : "2026-08-01T00:00:00.000Z" ,
16471676 ...( protection === "session"
@@ -1666,15 +1695,14 @@ describe("storage cleanup", () => {
16661695 const deleteRule = protection . startsWith ( "deleted" ) ;
16671696 let tombstoned = deleteRule && protection !== "deleted-event" ;
16681697 const removals : string [ ] = [ ] ;
1669- // A squash merge leaves the checkout's head outside the default branch.
1670- const squash = protection . startsWith ( "squash-" ) ;
1698+ const squash = protection . startsWith ( "squash-" ) || protection === "unchanged-squash" ;
16711699 const mergeRule =
16721700 protection === "merged" ||
16731701 protection === "unmerged" ||
1674- ( squash && protection !== "squash-unchanged-only " ) ;
1702+ protection . startsWith ( "squash-" ) ;
16751703 const unchangedRule =
1676- protection === "squash-unchanged-only" ||
16771704 protection === "unchanged" ||
1705+ protection === "unchanged-squash" ||
16781706 protection === "unchanged-two-worktrees" ||
16791707 protection === "diverged" ||
16801708 protection === "head-moved" ;
@@ -1828,27 +1856,37 @@ describe("storage cleanup", () => {
18281856 invalidateStatus : ( ) => Effect . void ,
18291857 branchPullRequest : ( _input , options ) => {
18301858 assert . strictEqual ( options ?. refresh , true ) ;
1831- assert . notStrictEqual ( protection , "squash- unchanged-only " ) ;
1832- if ( protection === "squash-lookup-failed" )
1859+ assert . notStrictEqual ( protection , "unchanged-squash " ) ;
1860+ if ( protection === "squash-lookup-failed" ) {
18331861 return Effect . fail (
1834- new GitManagerError ( {
1862+ new GitCommandError ( {
18351863 operation : "branchPullRequest" ,
1864+ command : "gh" ,
18361865 cwd : worktreePath ,
1837- detail : "host unavailable" ,
1866+ detail : "Host unavailable" ,
18381867 } ) ,
18391868 ) ;
1840- const pullRequest = makeBranchPullRequest (
1841- protection === "unmerged" ? "open" : "merged" ,
1842- ) ;
1843- if ( ! squash ) return Effect . succeed ( pullRequest ) ;
1869+ }
18441870 return Effect . succeed ( {
1845- ...pullRequest ,
1846- headRef : protection === "squash-other-head" ? "saved-feature" : "feature" ,
1847- baseRef : protection === "squash-other-base" ? "release" : "main" ,
1848- headSha :
1849- protection === "squash-no-head-sha"
1850- ? null
1851- : ( protection === "squash-later-commit" ? "e" : "a" ) . repeat ( 40 ) ,
1871+ ...makeBranchPullRequest (
1872+ protection === "unmerged" || protection === "squash-stale-merged"
1873+ ? "open"
1874+ : protection === "squash-closed"
1875+ ? "closed"
1876+ : "merged" ,
1877+ ) ,
1878+ headRef : protection === "squash-different-branch" ? "other" : "feature" ,
1879+ baseRef :
1880+ protection === "squash-release-base"
1881+ ? "release"
1882+ : protection === "squash-stack-base"
1883+ ? "stack-parent"
1884+ : "main" ,
1885+ ...( ! squash || protection === "squash-missing-head"
1886+ ? { }
1887+ : {
1888+ headSha : ( protection === "squash-later-commit" ? "c" : "a" ) . repeat ( 40 ) ,
1889+ } ) ,
18521890 } ) ;
18531891 } ,
18541892 } ) ,
@@ -1903,7 +1941,8 @@ describe("storage cleanup", () => {
19031941 headReads ++ ;
19041942 return {
19051943 commitSha :
1906- protection === "head-moved" && headReads > 1
1944+ ( protection === "head-moved" || protection === "squash-head-moved" ) &&
1945+ headReads > 1
19071946 ? "c" . repeat ( 40 )
19081947 : "a" . repeat ( 40 ) ,
19091948 } ;
@@ -2042,7 +2081,7 @@ describe("storage cleanup", () => {
20422081 protection === "files-disabled" ||
20432082 protection === "files-extended" ||
20442083 protection === "merged" ||
2045- protection === "squash-merged " ||
2084+ protection === "squash-exact-head " ||
20462085 protection === "unchanged" ||
20472086 protection === "unchanged-two-worktrees" ;
20482087 assert . strictEqual ( yield * fs . exists ( worktreePath ) , ! removed ) ;
0 commit comments