Skip to content

Commit df9c415

Browse files
committed
close
1 parent 74c4d47 commit df9c415

File tree

2 files changed

+33
-14
lines changed

2 files changed

+33
-14
lines changed

src/git/repo_storage.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::authorship::authorship_log::PromptRecord;
33
use crate::authorship::working_log::{CHECKPOINT_API_VERSION, Checkpoint, CheckpointKind};
44
use crate::error::GitAiError;
55
use crate::git::rewrite_log::{RewriteLogEvent, append_event_to_file};
6-
use crate::utils::debug_log;
6+
use crate::utils::{debug_log, normalize_to_posix};
77
use serde::{Deserialize, Serialize};
88
use sha2::{Digest, Sha256};
99
use std::collections::{HashMap, HashSet};
@@ -142,11 +142,21 @@ impl PersistedWorkingLog {
142142
}
143143

144144
pub fn set_dirty_files(&mut self, dirty_files: Option<HashMap<String, String>>) {
145-
self.dirty_files = dirty_files.map(|map| {
145+
println!("pre_transform dirty_files: {:?}", dirty_files);
146+
147+
let normalized_dirty_files = dirty_files.map(|map| {
146148
map.into_iter()
147-
.map(|(file_path, content)| (self.to_repo_relative_path(&file_path), content))
148-
.collect()
149+
.map(|(file_path, content)| {
150+
let relative_path = self.to_repo_relative_path(&file_path);
151+
let normalized_path = normalize_to_posix(&relative_path);
152+
(normalized_path, content)
153+
})
154+
.collect::<HashMap<_, _>>()
149155
});
156+
157+
self.dirty_files = normalized_dirty_files;
158+
159+
println!("setdirty_files: {:?}", self.dirty_files);
150160
}
151161

152162
pub fn reset_working_log(&self) -> Result<(), GitAiError> {

tests/ai_tab.rs

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,9 @@ fn test_ai_tab_e2e_handles_dirty_files_map() {
307307
println!("lib_file_path_str: {}", lib_file_path_str);
308308
println!("readme_file_path_str: {}", readme_file_path_str);
309309

310+
let working_logs = repo.current_working_logs();
311+
println!("dirty_files: {:?}", working_logs.dirty_files);
312+
310313
// Before edit snapshot includes all dirty files (AI target plus unrelated human edits)
311314
run_ai_tab_checkpoint(
312315
&repo,
@@ -329,6 +332,9 @@ fn test_ai_tab_e2e_handles_dirty_files_map() {
329332
.to_string();
330333
fs::write(&lib_file_path, &ai_content).unwrap();
331334

335+
let working_logs = repo.current_working_logs();
336+
println!("dirty_files: {:?}", working_logs.dirty_files);
337+
332338
run_ai_tab_checkpoint(
333339
&repo,
334340
json!({
@@ -344,17 +350,20 @@ fn test_ai_tab_e2e_handles_dirty_files_map() {
344350
}),
345351
);
346352

347-
// Debug: Check working logs before commit
353+
// // Debug: Check working logs before commit
354+
// let working_logs = repo.current_working_logs();
355+
// if let Ok(checkpoints) = working_logs.read_all_checkpoints() {
356+
// println!("Checkpoints before commit: {}", checkpoints.len());
357+
// for (i, cp) in checkpoints.iter().enumerate() {
358+
// println!("Checkpoint {}: kind={:?}, entries={}", i, cp.kind, cp.entries.len());
359+
// for entry in &cp.entries {
360+
// println!(" File: {}, attributions={}", entry.file, entry.attributions.len());
361+
// }
362+
// }
363+
// }
364+
348365
let working_logs = repo.current_working_logs();
349-
if let Ok(checkpoints) = working_logs.read_all_checkpoints() {
350-
println!("Checkpoints before commit: {}", checkpoints.len());
351-
for (i, cp) in checkpoints.iter().enumerate() {
352-
println!("Checkpoint {}: kind={:?}, entries={}", i, cp.kind, cp.entries.len());
353-
for entry in &cp.entries {
354-
println!(" File: {}, attributions={}", entry.file, entry.attributions.len());
355-
}
356-
}
357-
}
366+
println!("dirty_files: {:?}", working_logs.dirty_files);
358367

359368
repo.stage_all_and_commit("Record AI tab completion while other files dirty").unwrap();
360369

0 commit comments

Comments
 (0)