[app-server] feat: add old_content and new_content to FileChange update patches

This commit is contained in:
Owen Lin
2025-12-02 14:28:32 -08:00
parent 8532876ad8
commit ce7fc27f89
12 changed files with 221 additions and 6 deletions
+17
View File
@@ -1653,6 +1653,8 @@ pub enum FileChange {
Update {
unified_diff: String,
move_path: Option<PathBuf>,
old_content: String,
new_content: String,
},
}
@@ -1717,6 +1719,21 @@ mod tests {
assert!(event.as_legacy_events(false).is_empty());
}
#[test]
fn file_change_update_serializes_old_and_new_content() {
let change = FileChange::Update {
unified_diff: "--- a\n+++ b\n@@ -1 +1 @@\n-old\n+new\n".to_string(),
move_path: None,
old_content: "old\n".to_string(),
new_content: "new\n".to_string(),
};
let serialized = serde_json::to_value(change).expect("should serialize");
assert_eq!(serialized["old_content"], "old\n");
assert_eq!(serialized["new_content"], "new\n");
}
/// Serialize Event to verify that its JSON representation has the expected
/// amount of nesting.
#[test]