@@ -16,7 +16,7 @@ import { Logger } from '@shared/utils/logger'
1616export const create_temporary_checkpoint = async (
1717 workspace_provider : WorkspaceProvider
1818) : Promise < Checkpoint | undefined > => {
19- const workspace_folders = vscode . workspace . workspaceFolders
19+ const workspace_folders = vscode . workspace . workspaceFolders !
2020
2121 const folder_git_statuses = await Promise . all (
2222 workspace_folders . map ( ( folder ) => is_git_repository ( folder ) )
@@ -35,38 +35,59 @@ export const create_temporary_checkpoint = async (
3535 const git_data : Record < string , any > = { }
3636 let uses_git = false
3737
38- for ( const [ index , folder ] of workspace_folders . entries ( ) ) {
39- const has_git = folder_git_statuses [ index ]
38+ await Promise . all (
39+ workspace_folders . map ( async ( folder , index ) => {
40+ const has_git = folder_git_statuses [ index ]
41+ const folder_key = `${ index } -${ folder . name } `
4042
41- if ( has_git ) {
42- uses_git = true
43- const git_info = await get_git_info ( folder )
44- const diff = await get_git_diff ( folder )
43+ if ( has_git ) {
44+ uses_git = true
45+ const git_info = await get_git_info ( folder )
46+ const diff = await get_git_diff ( folder )
4547
46- if ( git_info && diff !== null ) {
47- const folder_name = folder . name
48- git_data [ folder_name ] = {
49- branch : git_info . branch ,
50- commit_hash : git_info . commit_hash ,
51- folder_name
52- }
48+ if ( git_info && diff !== null ) {
49+ git_data [ folder_key ] = {
50+ branch : git_info . branch ,
51+ commit_hash : git_info . commit_hash ,
52+ folder_name : folder_key
53+ }
54+
55+ const diff_file_path = path . join (
56+ checkpoint_dir_path ,
57+ `${ folder_key } .diff`
58+ )
59+ await vscode . workspace . fs . writeFile (
60+ vscode . Uri . file ( diff_file_path ) ,
61+ Buffer . from ( diff , 'utf8' )
62+ )
63+ } else {
64+ Logger . warn ( {
65+ function_name : 'create_temporary_checkpoint' ,
66+ message : `Failed to get git information for repository in ${ folder . name } . Falling back to file copy.`
67+ } )
68+ const dest_folder_path =
69+ workspace_folders . length > 1
70+ ? path . join ( checkpoint_dir_path , folder_key )
71+ : checkpoint_dir_path
72+ const dest_folder_uri = vscode . Uri . file ( dest_folder_path )
73+ if ( workspace_folders . length > 1 ) {
74+ await vscode . workspace . fs . createDirectory ( dest_folder_uri )
75+ }
5376
54- const diff_file_path = path . join (
55- checkpoint_dir_path ,
56- `${ folder_name } .diff`
57- )
58- await vscode . workspace . fs . writeFile (
59- vscode . Uri . file ( diff_file_path ) ,
60- Buffer . from ( diff , 'utf8' )
61- )
77+ const entries = await vscode . workspace . fs . readDirectory ( folder . uri )
78+ for ( const [ name ] of entries ) {
79+ await copy_optimised_recursively (
80+ vscode . Uri . joinPath ( folder . uri , name ) ,
81+ vscode . Uri . joinPath ( dest_folder_uri , name ) ,
82+ folder . uri . fsPath ,
83+ workspace_provider
84+ )
85+ }
86+ }
6287 } else {
63- Logger . warn ( {
64- function_name : 'create_temporary_checkpoint' ,
65- message : `Failed to get git information for repository in ${ folder . name } . Falling back to file copy.`
66- } )
6788 const dest_folder_path =
6889 workspace_folders . length > 1
69- ? path . join ( checkpoint_dir_path , folder . name )
90+ ? path . join ( checkpoint_dir_path , folder_key )
7091 : checkpoint_dir_path
7192 const dest_folder_uri = vscode . Uri . file ( dest_folder_path )
7293 if ( workspace_folders . length > 1 ) {
@@ -83,27 +104,8 @@ export const create_temporary_checkpoint = async (
83104 )
84105 }
85106 }
86- } else {
87- const dest_folder_path =
88- workspace_folders . length > 1
89- ? path . join ( checkpoint_dir_path , folder . name )
90- : checkpoint_dir_path
91- const dest_folder_uri = vscode . Uri . file ( dest_folder_path )
92- if ( workspace_folders . length > 1 ) {
93- await vscode . workspace . fs . createDirectory ( dest_folder_uri )
94- }
95-
96- const entries = await vscode . workspace . fs . readDirectory ( folder . uri )
97- for ( const [ name ] of entries ) {
98- await copy_optimised_recursively (
99- vscode . Uri . joinPath ( folder . uri , name ) ,
100- vscode . Uri . joinPath ( dest_folder_uri , name ) ,
101- folder . uri . fsPath ,
102- workspace_provider
103- )
104- }
105- }
106- }
107+ } )
108+ )
107109
108110 const active_tabs : CheckpointTab [ ] = [ ]
109111 const tab_groups = vscode . window . tabGroups . all
0 commit comments