@@ -1918,6 +1918,35 @@ it.layer(TestLayer)("GitVcsDriver core integration", (it) => {
19181918 } ) ,
19191919 ) ;
19201920
1921+ it . effect ( "does not start Git auto-maintenance from background upstream fetches" , ( ) =>
1922+ Effect . gen ( function * ( ) {
1923+ const cwd = yield * makeTmpDir ( ) ;
1924+ const remote = yield * makeTmpDir ( "git-vcs-driver-remote-" ) ;
1925+ const { initialBranch } = yield * initRepoWithCommit ( cwd ) ;
1926+ yield * git ( remote , [ "init" , "--bare" ] ) ;
1927+ yield * git ( cwd , [ "remote" , "add" , "origin" , remote ] ) ;
1928+ yield * git ( cwd , [ "push" , "-u" , "origin" , initialBranch ] ) ;
1929+ yield * git ( cwd , [ "repack" , "-d" ] ) ;
1930+ yield * writeTextFile ( cwd , "second.txt" , "second\n" ) ;
1931+ yield * git ( cwd , [ "add" , "second.txt" ] ) ;
1932+ yield * git ( cwd , [ "commit" , "-m" , "second commit" ] ) ;
1933+ yield * git ( cwd , [ "push" ] ) ;
1934+ yield * git ( cwd , [ "repack" , "-d" ] ) ;
1935+ // Two packs make `git gc --auto` due, and without detaching it would run inside the fetch.
1936+ yield * git ( cwd , [ "config" , "gc.autoPackLimit" , "1" ] ) ;
1937+ yield * git ( cwd , [ "config" , "gc.autoDetach" , "false" ] ) ;
1938+ yield * git ( cwd , [ "config" , "maintenance.autoDetach" , "false" ] ) ;
1939+ const packCount = git ( cwd , [ "count-objects" , "-v" ] ) . pipe (
1940+ Effect . map ( ( stdout ) => stdout . match ( / ^ p a c k s : ( \d + ) $ / m) ?. [ 1 ] ) ,
1941+ ) ;
1942+ assert . equal ( yield * packCount , "2" ) ;
1943+
1944+ yield * ( yield * GitVcsDriver . GitVcsDriver ) . statusDetailsRemote ( cwd ) ;
1945+
1946+ assert . equal ( yield * packCount , "2" ) ;
1947+ } ) ,
1948+ ) ;
1949+
19211950 it . effect ( "uses origin HEAD for default-branch detection with a non-origin upstream" , ( ) =>
19221951 Effect . gen ( function * ( ) {
19231952 const cwd = yield * makeTmpDir ( ) ;
0 commit comments