@@ -612,6 +612,41 @@ test("files tracked in snapshot but now gitignored are filtered out", async () =
612612 } )
613613} )
614614
615+ test ( "gitignore updated between track calls filters from diff" , async ( ) => {
616+ await using tmp = await bootstrap ( )
617+ await Instance . provide ( {
618+ directory : tmp . path ,
619+ fn : async ( ) => {
620+ // a.txt is already committed from bootstrap - track it in snapshot
621+ const before = await Snapshot . track ( )
622+ expect ( before ) . toBeTruthy ( )
623+
624+ // Modify a.txt (so it appears in diff-files)
625+ await Filesystem . write ( `${ tmp . path } /a.txt` , "modified content" )
626+
627+ // Now add gitignore that would exclude a.txt
628+ await Filesystem . write ( `${ tmp . path } /.gitignore` , "a.txt\n" )
629+
630+ // Also modify b.txt which is not gitignored
631+ await Filesystem . write ( `${ tmp . path } /b.txt` , "also modified" )
632+
633+ // Second track - should not include a.txt even though it changed
634+ const after = await Snapshot . track ( )
635+ expect ( after ) . toBeTruthy ( )
636+
637+ // Verify a.txt is NOT in the diff between snapshots
638+ const diffs = await Snapshot . diffFull ( before ! , after ! )
639+ expect ( diffs . some ( ( x ) => x . file === "a.txt" ) ) . toBe ( false )
640+
641+ // But .gitignore should be in the diff
642+ expect ( diffs . some ( ( x ) => x . file === ".gitignore" ) ) . toBe ( true )
643+
644+ // b.txt should be in the diff (not gitignored)
645+ expect ( diffs . some ( ( x ) => x . file === "b.txt" ) ) . toBe ( true )
646+ } ,
647+ } )
648+ } )
649+
615650test ( "git info exclude changes" , async ( ) => {
616651 await using tmp = await bootstrap ( )
617652 await Instance . provide ( {
0 commit comments