mirror of
https://github.com/instructkr/claude-code.git
synced 2026-05-28 16:36:45 +00:00
fix(#710): diff --output-format json adds missing action:diff and working_directory fields to both ok and error branches
This commit is contained in:
@@ -7680,8 +7680,10 @@ fn render_diff_json_for(cwd: &Path) -> Result<serde_json::Value, Box<dyn std::er
|
||||
if !in_git_repo {
|
||||
return Ok(serde_json::json!({
|
||||
"kind": "diff",
|
||||
"action": "diff",
|
||||
"status": "error",
|
||||
"result": "no_git_repo",
|
||||
"working_directory": cwd.display().to_string(),
|
||||
"detail": format!("{} is not inside a git project", cwd.display()),
|
||||
}));
|
||||
}
|
||||
@@ -7689,7 +7691,9 @@ fn render_diff_json_for(cwd: &Path) -> Result<serde_json::Value, Box<dyn std::er
|
||||
let unstaged = run_git_diff_command_in(cwd, &["diff"])?;
|
||||
Ok(serde_json::json!({
|
||||
"kind": "diff",
|
||||
"action": "diff",
|
||||
"status": "ok",
|
||||
"working_directory": cwd.display().to_string(),
|
||||
"result": if staged.trim().is_empty() && unstaged.trim().is_empty() { "clean" } else { "changes" },
|
||||
"staged": staged.trim(),
|
||||
"unstaged": unstaged.trim(),
|
||||
|
||||
@@ -1114,6 +1114,18 @@ fn diff_json_has_status_and_result_field_702() {
|
||||
parsed.get("result").is_some(),
|
||||
"diff JSON must have result field"
|
||||
);
|
||||
// #710: diff JSON must have action:diff and working_directory
|
||||
assert_eq!(
|
||||
parsed["action"], "diff",
|
||||
"diff JSON must have action:diff (#710)"
|
||||
);
|
||||
assert!(
|
||||
parsed
|
||||
.get("working_directory")
|
||||
.and_then(|v| v.as_str())
|
||||
.is_some(),
|
||||
"diff JSON must have working_directory field (#710)"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user