@@ -16,32 +16,32 @@ export namespace Snapshot {
1616 const log = Log . create ( { service : "snapshot" } )
1717
1818 export async function create ( sessionID : string ) {
19+ log . info ( "creating snapshot" )
1920 const app = App . info ( )
2021 const git = gitdir ( sessionID )
2122 const files = await Ripgrep . files ( {
2223 cwd : app . path . cwd ,
2324 limit : app . git ? undefined : 1000 ,
2425 } )
26+ log . info ( "found files" , { count : files . length } )
2527 // not a git repo and too big to snapshot
2628 if ( ! app . git && files . length === 1000 ) return
2729 await init ( {
2830 dir : app . path . cwd ,
2931 gitdir : git ,
3032 fs,
3133 } )
34+ log . info ( "initialized" )
3235 const status = await statusMatrix ( {
3336 fs,
3437 gitdir : git ,
3538 dir : app . path . cwd ,
3639 } )
37- await add ( {
38- fs,
39- gitdir : git ,
40- parallel : true ,
41- dir : app . path . cwd ,
42- filepath : files ,
40+ log . info ( "matrix" , {
41+ count : status . length ,
4342 } )
44- for ( const [ file , _head , workdir , stage ] of status ) {
43+ const added = [ ]
44+ for ( const [ file , head , workdir , stage ] of status ) {
4545 if ( workdir === 0 && stage === 1 ) {
4646 log . info ( "remove" , { file } )
4747 await remove ( {
@@ -50,8 +50,21 @@ export namespace Snapshot {
5050 dir : app . path . cwd ,
5151 filepath : file ,
5252 } )
53+ continue
54+ }
55+ if ( workdir !== head ) {
56+ added . push ( file )
5357 }
5458 }
59+ log . info ( "removed files" )
60+ await add ( {
61+ fs,
62+ gitdir : git ,
63+ parallel : true ,
64+ dir : app . path . cwd ,
65+ filepath : added ,
66+ } )
67+ log . info ( "added files" )
5568 const result = await commit ( {
5669 fs,
5770 gitdir : git ,
0 commit comments