@@ -76,25 +76,57 @@ pub fn list(
7676 repositories:: workspaces:: status:: status_from_dir ( workspace, directory) ?;
7777
7878 // Step 3: Build status maps from staged files
79- let mut additions_map: HashMap < String , StagedEntryStatus > = HashMap :: new ( ) ;
80- let mut other_changes_map: HashMap < String , StagedEntryStatus > = HashMap :: new ( ) ;
81-
82- for ( file_path, entry) in workspace_changes. staged_files . iter ( ) {
83- let status = entry. status . clone ( ) ;
84- if status == StagedEntryStatus :: Added {
85- // For added files, use the full path as key (relative to repo root)
86- let key = file_path. to_str ( ) . unwrap ( ) . to_string ( ) ;
87- additions_map. insert ( key, status) ;
88- } else {
89- // For modified or removed files, use the filename as key
90- let key = file_path. file_name ( ) . unwrap ( ) . to_string_lossy ( ) . to_string ( ) ;
91- other_changes_map. insert ( key, status) ;
79+ let ( additions, removed, modified) = {
80+ workspace_changes. staged_files . iter ( ) . fold (
81+ ( HashMap :: new ( ) , HashMap :: new ( ) , HashMap :: new ( ) ) ,
82+ |( mut additions, mut removed, mut modified) , ( file_path, entry) | {
83+
84+ if let Some ( maybe_map_to_be_modified) = match entry. status {
85+ StagedEntryStatus :: Added => Some ( & mut additions) ,
86+ StagedEntryStatus :: Modified => Some ( & mut modified) ,
87+ StagedEntryStatus :: Removed => Some ( & mut removed) ,
88+ StagedEntryStatus :: Unmodified => None ,
89+ } {
90+ let Some ( key) = file_path. file_name ( ) {
91+ map_to_be_modified. insert ( key, status) ;
92+ } else {
93+ log:: warn!( "[skip] Could not retrieve file name for: '{file_path:?}' in workspace: {}" , workspace. id)
94+ }
95+ }
96+
97+ ( additions, removed, modified
9298 }
93- }
99+ )
100+ } ;
94101
95102 // Step 4: Apply workspace changes to commit entries
96103 let mut merged_entries: Vec < EMetadataEntry > = Vec :: new ( ) ;
97104
105+ let merged_entries = commit_entries. into_iter ( )
106+ . filter_map ( |entry| {
107+
108+ let filename = & entry. filename ;
109+ if let Some ( status) = other_changes_map. get ( filename) {
110+ match status {
111+ // Don't show removed files
112+ StagedEntryStatus :: Removed => None ,
113+ _ => {
114+ // Still present => must be modified (either modified or unmodified)
115+ let mut ws_entry = WorkspaceMetadataEntry :: from_metadata_entry ( entry) ;
116+ ws_entry. changes = Some ( WorkspaceChanges {
117+ status : status. clone ( ) ,
118+ } ) ;
119+ Some ( EMetadataEntry :: WorkspaceMetadataEntry ( ws_entry) )
120+ }
121+ }
122+ } else {
123+ // Unmodified commit entry
124+ let ws_entry = WorkspaceMetadataEntry :: from_metadata_entry ( entry) ;
125+ merged_entries. push ( EMetadataEntry :: WorkspaceMetadataEntry ( ws_entry) ) ;
126+ }
127+
128+ } ) ;
129+
98130 for entry in commit_entries {
99131 let filename = & entry. filename ;
100132 if let Some ( status) = other_changes_map. get ( filename) {
@@ -171,11 +203,12 @@ pub fn list(
171203
172204 // Step 8: Build dir metadata entry for the directory itself
173205 let dir_entry = if let Some ( ref dir) = maybe_dir {
174- let dir_metadata = core:: v_latest:: entries:: dir_node_to_metadata_entry_public (
206+ let dir_metadata = core:: v_latest:: entries:: dir_node_to_metadata_entry (
175207 base_repo,
176208 dir,
177209 & parsed_resource,
178210 & mut found_commits,
211+ false ,
179212 ) ?;
180213 dir_metadata. map ( |e| {
181214 EMetadataEntry :: WorkspaceMetadataEntry ( WorkspaceMetadataEntry :: from_metadata_entry ( e) )
0 commit comments