@@ -308,9 +308,13 @@ it.effect("checkpoint capture skips an ignored project while keeping its allowed
308308 } ) . pipe ( Effect . scoped , Effect . provide ( layerGitContract ) ) ,
309309) ;
310310
311- it . effect (
312- "checkpoint capture keeps tracked edits but excludes new files in a project ignored later" ,
313- ( ) =>
311+ it . effect . each ( [
312+ { tracking : "committed-only" , committed : [ "committed.txt" ] , staged : [ ] } ,
313+ { tracking : "staged-only" , committed : [ ] , staged : [ "staged.txt" ] } ,
314+ { tracking : "mixed" , committed : [ "committed.txt" ] , staged : [ "staged.txt" ] } ,
315+ ] ) (
316+ "checkpoint capture keeps $tracking tracked edits but excludes new files in a project ignored later" ,
317+ ( { committed, staged } ) =>
314318 Effect . gen ( function * ( ) {
315319 const fs = yield * FileSystem . FileSystem ;
316320 const path = yield * Path . Path ;
@@ -319,25 +323,41 @@ it.effect(
319323 const { git, checkpointRef } = yield * makeCheckpointFixture ( driver , parent ) ;
320324 const cwd = path . join ( parent , "sub" ) ;
321325 yield * fs . makeDirectory ( cwd ) ;
322- yield * fs . writeFileString ( path . join ( cwd , "tracked.txt" ) , "before\n" ) ;
323- yield * git ( [ "add" , "sub" ] ) ;
324- yield * git ( [ "commit" , "-m" , "track project" ] ) ;
326+ for ( const file of committed ) {
327+ yield * fs . writeFileString ( path . join ( cwd , file ) , "committed\n" ) ;
328+ yield * git ( [ "add" , `sub/${ file } ` ] ) ;
329+ }
330+ if ( committed . length > 0 ) {
331+ yield * git ( [ "commit" , "-m" , "track project" ] ) ;
332+ }
333+ for ( const file of staged ) {
334+ yield * fs . writeFileString ( path . join ( cwd , file ) , "staged\n" ) ;
335+ yield * git ( [ "add" , `sub/${ file } ` ] ) ;
336+ }
337+ const tracked = [ ...committed , ...staged ] ;
325338 yield * fs . writeFileString ( path . join ( parent , ".gitignore" ) , "sub/\n" ) ;
326- yield * fs . writeFileString ( path . join ( cwd , "tracked.txt" ) , "after\n" ) ;
339+ for ( const file of tracked ) {
340+ yield * fs . writeFileString ( path . join ( cwd , file ) , `${ file } working\n` ) ;
341+ }
327342 yield * fs . writeFileString ( path . join ( cwd , "secret.txt" ) , "private\n" ) ;
328343 const originalIndex = yield * fs . readFile ( path . join ( parent , ".git" , "index" ) ) ;
329344
330- yield * driver . checkpoints . captureCheckpoint ( { cwd, checkpointRef } ) ;
331-
332- assert . strictEqual (
333- ( yield * git ( [ "show" , `${ checkpointRef } :sub/tracked.txt` ] ) ) . stdout ,
334- "after\n" ,
345+ const captured = yield * Effect . result (
346+ driver . checkpoints . captureCheckpoint ( { cwd, checkpointRef } ) ,
335347 ) ;
348+
349+ assert . deepEqual ( yield * fs . readFile ( path . join ( parent , ".git" , "index" ) ) , originalIndex ) ;
350+ if ( captured . _tag === "Failure" ) return yield * captured . failure ;
336351 assert . strictEqual (
337352 ( yield * git ( [ "ls-tree" , "-r" , "--name-only" , checkpointRef , "--" , "sub" ] ) ) . stdout ,
338- "sub/ tracked.txt\n" ,
353+ tracked . map ( ( file ) => `sub/ ${ file } \n` ) . join ( "" ) ,
339354 ) ;
340- assert . deepEqual ( yield * fs . readFile ( path . join ( parent , ".git" , "index" ) ) , originalIndex ) ;
355+ for ( const file of tracked ) {
356+ assert . strictEqual (
357+ ( yield * git ( [ "show" , `${ checkpointRef } :sub/${ file } ` ] ) ) . stdout ,
358+ `${ file } working\n` ,
359+ ) ;
360+ }
341361 } ) . pipe ( Effect . scoped , Effect . provide ( layerGitContract ) ) ,
342362) ;
343363
0 commit comments