@@ -2681,117 +2681,124 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
26812681 } ) ,
26822682 ) ;
26832683
2684- it . effect ( "keeps isolated fetch refs outside the shared repository" , ( ) =>
2685- Effect . scoped (
2686- Effect . gen ( function * ( ) {
2687- const cwd = yield * makeTmpDir ( ) ;
2688- const remote = yield * makeTmpDir ( "git-vcs-driver-remote-" ) ;
2689- const updater = yield * makeTmpDir ( "git-vcs-driver-updater-" ) ;
2690- const { initialBranch } = yield * initRepoWithCommit ( cwd ) ;
2691- yield * git ( remote , [ "init" , "--bare" ] ) ;
2692- yield * git ( cwd , [ "remote" , "add" , "origin" , remote ] ) ;
2693- yield * git ( cwd , [ "push" , "-u" , "origin" , initialBranch ] ) ;
2694-
2695- yield * git ( updater , [ "clone" , remote , "." ] ) ;
2696- yield * git ( updater , [ "config" , "user.email" , "[email protected] " ] ) ; 2697- yield * git ( updater , [ "config" , "user.name" , "Test" ] ) ;
2698- yield * writeTextFile ( updater , "remote.txt" , "remote\n" ) ;
2699- yield * git ( updater , [ "add" , "remote.txt" ] ) ;
2700- yield * git ( updater , [ "commit" , "-m" , "remote commit" ] ) ;
2701- yield * git ( updater , [ "push" , "origin" , initialBranch ] ) ;
2702- const concurrentCommit = yield * git ( cwd , [
2703- "commit-tree" ,
2704- "HEAD^{tree}" ,
2705- "-p" ,
2706- "HEAD" ,
2707- "-m" ,
2708- "concurrent ref update" ,
2709- ] ) ;
2710-
2711- const delegate = yield * ChildProcessSpawner . ChildProcessSpawner ;
2712- let isolatedFetchCount = 0 ;
2713- const isolatedFetchExited = yield * Deferred . make < void > ( ) ;
2714- const releaseIsolatedFetch = yield * Deferred . make < void > ( ) ;
2715- yield * Effect . addFinalizer ( ( ) =>
2716- Deferred . succeed ( releaseIsolatedFetch , undefined ) . pipe ( Effect . asVoid ) ,
2717- ) ;
2718- const blockingSpawner = ChildProcessSpawner . make ( ( command ) =>
2719- Effect . gen ( function * ( ) {
2720- const handle = yield * delegate . spawn ( command ) ;
2721- if (
2722- ! ChildProcess . isStandardCommand ( command ) ||
2723- ! command . args . includes ( "--no-write-fetch-head" ) ||
2724- command . options . env ?. GIT_OBJECT_DIRECTORY === undefined
2725- ) {
2726- return handle ;
2727- }
2728- isolatedFetchCount += 1 ;
2729- return ChildProcessSpawner . makeHandle ( {
2730- pid : handle . pid ,
2731- exitCode : handle . exitCode . pipe (
2732- Effect . tap ( ( ) => Deferred . succeed ( isolatedFetchExited , undefined ) ) ,
2733- Effect . tap ( ( ) => Deferred . await ( releaseIsolatedFetch ) ) ,
2734- ) ,
2735- isRunning : handle . isRunning ,
2736- kill : handle . kill ,
2737- unref : handle . unref ,
2738- stdin : handle . stdin ,
2739- stdout : handle . stdout ,
2740- stderr : handle . stderr ,
2741- all : handle . all ,
2742- getInputFd : handle . getInputFd ,
2743- getOutputFd : handle . getOutputFd ,
2744- } ) ;
2745- } ) ,
2746- ) ;
2747- const driver = yield * makeGitVcsDriverCore ( ) . pipe (
2748- Effect . provideService ( ChildProcessSpawner . ChildProcessSpawner , blockingSpawner ) ,
2749- Effect . provide ( layerServerConfig ) ,
2750- ) ;
2751- const refresh = yield * driver
2752- . statusDetailsRemote ( cwd )
2753- . pipe ( Effect . forkChild ( { startImmediately : true } ) ) ;
2754-
2755- yield * Deferred . await ( isolatedFetchExited ) ;
2756- const sharedTemporaryRefs = yield * git ( cwd , [
2757- "for-each-ref" ,
2758- "--format=%(refname)" ,
2759- "refs/t3-status-fetch" ,
2760- ] ) ;
2761- const fileSystem = yield * FileSystem . FileSystem ;
2762- const pathService = yield * Path . Path ;
2763- const gitCommonDirRaw = yield * git ( cwd , [ "rev-parse" , "--git-common-dir" ] ) ;
2764- const gitCommonDir = pathService . isAbsolute ( gitCommonDirRaw )
2765- ? gitCommonDirRaw
2766- : pathService . resolve ( cwd , gitCommonDirRaw ) ;
2767- const isolatedFetchRoot = pathService . join ( gitCommonDir , "objects" , "t3-status-fetch" ) ;
2768- const [ isolatedGitDir ] = yield * fileSystem . readDirectory ( isolatedFetchRoot , {
2769- recursive : false ,
2770- } ) ;
2771- if ( isolatedGitDir === undefined ) {
2772- return yield * Effect . die ( "expected an isolated Git status fetch directory" ) ;
2773- }
2774- const privateTemporaryRefs = yield * git ( cwd , [
2775- "--git-dir" ,
2776- pathService . join ( isolatedFetchRoot , isolatedGitDir ) ,
2777- "for-each-ref" ,
2778- "--format=%(refname)" ,
2779- "refs/t3-status-fetch" ,
2780- ] ) ;
2781-
2782- assert . equal ( sharedTemporaryRefs , "" ) ;
2783- assert . match ( privateTemporaryRefs , / \/ u p s t r e a m $ / u) ;
2784-
2785- yield * git ( cwd , [ "update-ref" , `refs/remotes/origin/${ initialBranch } ` , concurrentCommit ] ) ;
2786- yield * Deferred . succeed ( releaseIsolatedFetch , undefined ) ;
2787- const refreshedStatus = yield * Fiber . join ( refresh ) ;
2788- assert . equal ( refreshedStatus . behindCount , 1 ) ;
2789-
2790- yield * TestClock . adjust ( "16 seconds" ) ;
2791- yield * driver . statusDetailsRemote ( cwd ) ;
2792- assert . equal ( isolatedFetchCount , 2 ) ;
2793- } ) ,
2794- ) ,
2684+ it . effect . each ( [ "sha1" , "sha256" ] as const ) (
2685+ "keeps isolated fetch refs outside the shared repository (%s)" ,
2686+ ( objectFormat ) =>
2687+ Effect . scoped (
2688+ Effect . gen ( function * ( ) {
2689+ const cwd = yield * makeTmpDir ( ) ;
2690+ const remote = yield * makeTmpDir ( "git-vcs-driver-remote-" ) ;
2691+ const updater = yield * makeTmpDir ( "git-vcs-driver-updater-" ) ;
2692+ yield * git ( cwd , [ "init" , `--object-format=${ objectFormat } ` ] ) ;
2693+ const { initialBranch } = yield * initRepoWithCommit ( cwd ) ;
2694+ yield * git ( remote , [ "init" , "--bare" , `--object-format=${ objectFormat } ` ] ) ;
2695+ yield * git ( cwd , [ "remote" , "add" , "origin" , remote ] ) ;
2696+ yield * git ( cwd , [ "push" , "-u" , "origin" , initialBranch ] ) ;
2697+
2698+ yield * git ( updater , [ "clone" , remote , "." ] ) ;
2699+ yield * git ( updater , [ "config" , "user.email" , "[email protected] " ] ) ; 2700+ yield * git ( updater , [ "config" , "user.name" , "Test" ] ) ;
2701+ yield * writeTextFile ( updater , "remote.txt" , "remote\n" ) ;
2702+ yield * git ( updater , [ "add" , "remote.txt" ] ) ;
2703+ yield * git ( updater , [ "commit" , "-m" , "remote commit" ] ) ;
2704+ yield * git ( updater , [ "push" , "origin" , initialBranch ] ) ;
2705+ const concurrentCommit = yield * git ( cwd , [
2706+ "commit-tree" ,
2707+ "HEAD^{tree}" ,
2708+ "-p" ,
2709+ "HEAD" ,
2710+ "-m" ,
2711+ "concurrent ref update" ,
2712+ ] ) ;
2713+
2714+ const delegate = yield * ChildProcessSpawner . ChildProcessSpawner ;
2715+ let isolatedFetchCount = 0 ;
2716+ const isolatedFetchExited = yield * Deferred . make < void > ( ) ;
2717+ const releaseIsolatedFetch = yield * Deferred . make < void > ( ) ;
2718+ yield * Effect . addFinalizer ( ( ) =>
2719+ Deferred . succeed ( releaseIsolatedFetch , undefined ) . pipe ( Effect . asVoid ) ,
2720+ ) ;
2721+ const blockingSpawner = ChildProcessSpawner . make ( ( command ) =>
2722+ Effect . gen ( function * ( ) {
2723+ const handle = yield * delegate . spawn ( command ) ;
2724+ if (
2725+ ! ChildProcess . isStandardCommand ( command ) ||
2726+ ! command . args . includes ( "--no-write-fetch-head" ) ||
2727+ command . options . env ?. GIT_OBJECT_DIRECTORY === undefined
2728+ ) {
2729+ return handle ;
2730+ }
2731+ isolatedFetchCount += 1 ;
2732+ return ChildProcessSpawner . makeHandle ( {
2733+ pid : handle . pid ,
2734+ exitCode : handle . exitCode . pipe (
2735+ Effect . tap ( ( ) => Deferred . succeed ( isolatedFetchExited , undefined ) ) ,
2736+ Effect . tap ( ( ) => Deferred . await ( releaseIsolatedFetch ) ) ,
2737+ ) ,
2738+ isRunning : handle . isRunning ,
2739+ kill : handle . kill ,
2740+ unref : handle . unref ,
2741+ stdin : handle . stdin ,
2742+ stdout : handle . stdout ,
2743+ stderr : handle . stderr ,
2744+ all : handle . all ,
2745+ getInputFd : handle . getInputFd ,
2746+ getOutputFd : handle . getOutputFd ,
2747+ } ) ;
2748+ } ) ,
2749+ ) ;
2750+ const driver = yield * makeGitVcsDriverCore ( ) . pipe (
2751+ Effect . provideService ( ChildProcessSpawner . ChildProcessSpawner , blockingSpawner ) ,
2752+ Effect . provide ( layerServerConfig ) ,
2753+ ) ;
2754+ const refresh = yield * driver
2755+ . statusDetailsRemote ( cwd )
2756+ . pipe ( Effect . forkChild ( { startImmediately : true } ) ) ;
2757+
2758+ yield * Deferred . await ( isolatedFetchExited ) ;
2759+ const sharedTemporaryRefs = yield * git ( cwd , [
2760+ "for-each-ref" ,
2761+ "--format=%(refname)" ,
2762+ "refs/t3-status-fetch" ,
2763+ ] ) ;
2764+ const fileSystem = yield * FileSystem . FileSystem ;
2765+ const pathService = yield * Path . Path ;
2766+ const gitCommonDirRaw = yield * git ( cwd , [ "rev-parse" , "--git-common-dir" ] ) ;
2767+ const gitCommonDir = pathService . isAbsolute ( gitCommonDirRaw )
2768+ ? gitCommonDirRaw
2769+ : pathService . resolve ( cwd , gitCommonDirRaw ) ;
2770+ const isolatedFetchRoot = pathService . join ( gitCommonDir , "objects" , "t3-status-fetch" ) ;
2771+ const [ isolatedGitDir ] = yield * fileSystem . readDirectory ( isolatedFetchRoot , {
2772+ recursive : false ,
2773+ } ) ;
2774+ if ( isolatedGitDir === undefined ) {
2775+ return yield * Effect . die ( "expected an isolated Git status fetch directory" ) ;
2776+ }
2777+ const privateTemporaryRefs = yield * git ( cwd , [
2778+ "--git-dir" ,
2779+ pathService . join ( isolatedFetchRoot , isolatedGitDir ) ,
2780+ "for-each-ref" ,
2781+ "--format=%(refname)" ,
2782+ "refs/t3-status-fetch" ,
2783+ ] ) ;
2784+
2785+ assert . equal ( sharedTemporaryRefs , "" ) ;
2786+ assert . match ( privateTemporaryRefs , / \/ u p s t r e a m $ / u) ;
2787+
2788+ yield * git ( cwd , [
2789+ "update-ref" ,
2790+ `refs/remotes/origin/${ initialBranch } ` ,
2791+ concurrentCommit ,
2792+ ] ) ;
2793+ yield * Deferred . succeed ( releaseIsolatedFetch , undefined ) ;
2794+ const refreshedStatus = yield * Fiber . join ( refresh ) ;
2795+ assert . equal ( refreshedStatus . behindCount , 1 ) ;
2796+
2797+ yield * TestClock . adjust ( "16 seconds" ) ;
2798+ yield * driver . statusDetailsRemote ( cwd ) ;
2799+ assert . equal ( isolatedFetchCount , 2 ) ;
2800+ } ) ,
2801+ ) ,
27952802 ) ;
27962803
27972804 it . effect ( "cleans partial packs after repeated status fetch timeouts" , ( ) =>
@@ -2869,6 +2876,10 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
28692876 const otherPack = path . join ( commonDir , "objects" , "pack" , "tmp_pack_other_operation" ) ;
28702877 yield * fs . makeDirectory ( path . dirname ( otherPack ) , { recursive : true } ) ;
28712878 yield * fs . writeFileString ( otherPack , "another operation's data" ) ;
2879+ const oldTime = DateTime . toDateUtc (
2880+ DateTime . subtractDuration ( yield * DateTime . now , Duration . hours ( 2 ) ) ,
2881+ ) ;
2882+ yield * fs . utimes ( otherPack , oldTime , oldTime ) ;
28722883 const delegate = yield * ChildProcessSpawner . ChildProcessSpawner ;
28732884
28742885 for ( let attempt = 0 ; attempt < 3 ; attempt ++ ) {
@@ -2908,7 +2919,7 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
29082919 ) ;
29092920 const driver = yield * makeGitVcsDriverCore ( ) . pipe (
29102921 Effect . provideService ( ChildProcessSpawner . ChildProcessSpawner , spawner ) ,
2911- Effect . provide ( ServerConfigLayer ) ,
2922+ Effect . provide ( layerServerConfig ) ,
29122923 ) ;
29132924 const refresh = yield * driver
29142925 . statusDetailsRemote ( cwd )
@@ -3086,7 +3097,7 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
30863097 yield * git ( remote , [ "init" , "--bare" ] ) ;
30873098 yield * git ( cwd , [ "remote" , "add" , "origin" , remote ] ) ;
30883099 yield * git ( cwd , [ "push" , "-u" , "origin" , "main" ] ) ;
3089- yield * git ( remote , [ "symbolic-ref" , "HEAD" , "refs/heads/main" ] ) ;
3100+ yield * git ( remote , [ "--git-dir" , remote , " symbolic-ref", "HEAD" , "refs/heads/main" ] ) ;
30903101 yield * git ( cwd , [ "symbolic-ref" , "refs/remotes/origin/HEAD" , "refs/remotes/origin/main" ] ) ;
30913102 yield * git ( cwd , [ "checkout" , "-b" , "feature/default-refresh" ] ) ;
30923103 yield * writeTextFile ( cwd , "feature.txt" , "feature\n" ) ;
@@ -3122,7 +3133,7 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
31223133 yield * git ( remote , [ "init" , "--bare" ] ) ;
31233134 yield * git ( cwd , [ "remote" , "add" , "origin" , remote ] ) ;
31243135 yield * git ( cwd , [ "push" , "-u" , "origin" , "main" ] ) ;
3125- yield * git ( remote , [ "symbolic-ref" , "HEAD" , "refs/heads/main" ] ) ;
3136+ yield * git ( remote , [ "--git-dir" , remote , " symbolic-ref", "HEAD" , "refs/heads/main" ] ) ;
31263137 yield * git ( cwd , [
31273138 "symbolic-ref" ,
31283139 "refs/remotes/origin/HEAD" ,
0 commit comments