(
git_repo: &GitRepository,
commit_oid: Oid,
parent_oid: Oid,
tree: &Tree<'_>,
parent_tree: &Tree<'_>,
)
| 4403 | } |
| 4404 | |
| 4405 | fn parse_diff_files_via_git_cli( |
| 4406 | git_repo: &GitRepository, |
| 4407 | commit_oid: Oid, |
| 4408 | parent_oid: Oid, |
| 4409 | tree: &Tree<'_>, |
| 4410 | parent_tree: &Tree<'_>, |
| 4411 | ) -> CliResult<Vec<ParsedFile>> { |
| 4412 | let repo_root = git_repo.path().parent().ok_or_else(|| CliError::GitError { |
| 4413 | message: "Failed to locate git repository root".to_string(), |
| 4414 | })?; |
| 4415 | |
| 4416 | let output = Command::new("git") |
| 4417 | .arg("-C") |
| 4418 | .arg(repo_root) |
| 4419 | .arg("diff-tree") |
| 4420 | .arg("-r") |
| 4421 | .arg("--name-status") |
| 4422 | .arg("-M") |
| 4423 | .arg(parent_oid.to_string()) |
| 4424 | .arg(commit_oid.to_string()) |
| 4425 | .output() |
| 4426 | .map_err(|e| CliError::GitError { |
| 4427 | message: format!("Failed to run git diff-tree fallback: {}", e), |
| 4428 | })?; |
| 4429 | |
| 4430 | if !output.status.success() { |
| 4431 | return Err(CliError::GitError { |
| 4432 | message: format!( |
| 4433 | "git diff-tree fallback failed: {}", |
| 4434 | String::from_utf8_lossy(&output.stderr).trim() |
| 4435 | ), |
| 4436 | }); |
| 4437 | } |
| 4438 | |
| 4439 | let mut files = Vec::new(); |
| 4440 | for line in String::from_utf8_lossy(&output.stdout).lines() { |
| 4441 | if line.is_empty() { |
| 4442 | continue; |
| 4443 | } |
| 4444 | let mut parts = line.split('\t'); |
| 4445 | let status = parts.next().unwrap_or_default(); |
| 4446 | let Some(kind) = status.chars().next() else { |
| 4447 | continue; |
| 4448 | }; |
| 4449 | |
| 4450 | match kind { |
| 4451 | 'A' => { |
| 4452 | let Some(path) = parts.next() else { continue }; |
| 4453 | files.push(ParsedFile { |
| 4454 | path: path.to_string(), |
| 4455 | operation: FileOperation::Added, |
| 4456 | new_content: get_file_content(git_repo, tree, path).ok(), |
| 4457 | old_content: None, |
| 4458 | diff_lines: None, |
| 4459 | old_path: None, |
| 4460 | }); |
| 4461 | } |
| 4462 | 'M' => { |
no test coverage detected