(
git_repo: &GitRepository,
commit_oid: Oid,
parent_oid: Oid,
tree: &Tree<'_>,
parent_tree: &Tree<'_>,
)
| 4004 | } |
| 4005 | |
| 4006 | fn parse_diff_files_via_git_cli( |
| 4007 | git_repo: &GitRepository, |
| 4008 | commit_oid: Oid, |
| 4009 | parent_oid: Oid, |
| 4010 | tree: &Tree<'_>, |
| 4011 | parent_tree: &Tree<'_>, |
| 4012 | ) -> CliResult<Vec<ParsedFile>> { |
| 4013 | let repo_root = git_repo.path().parent().ok_or_else(|| CliError::GitError { |
| 4014 | message: "Failed to locate git repository root".to_string(), |
| 4015 | })?; |
| 4016 | |
| 4017 | let output = Command::new("git") |
| 4018 | .arg("-C") |
| 4019 | .arg(repo_root) |
| 4020 | .arg("diff-tree") |
| 4021 | .arg("-r") |
| 4022 | .arg("--name-status") |
| 4023 | .arg("-M") |
| 4024 | .arg(parent_oid.to_string()) |
| 4025 | .arg(commit_oid.to_string()) |
| 4026 | .output() |
| 4027 | .map_err(|e| CliError::GitError { |
| 4028 | message: format!("Failed to run git diff-tree fallback: {}", e), |
| 4029 | })?; |
| 4030 | |
| 4031 | if !output.status.success() { |
| 4032 | return Err(CliError::GitError { |
| 4033 | message: format!( |
| 4034 | "git diff-tree fallback failed: {}", |
| 4035 | String::from_utf8_lossy(&output.stderr).trim() |
| 4036 | ), |
| 4037 | }); |
| 4038 | } |
| 4039 | |
| 4040 | let mut files = Vec::new(); |
| 4041 | for line in String::from_utf8_lossy(&output.stdout).lines() { |
| 4042 | if line.is_empty() { |
| 4043 | continue; |
| 4044 | } |
| 4045 | let mut parts = line.split('\t'); |
| 4046 | let status = parts.next().unwrap_or_default(); |
| 4047 | let Some(kind) = status.chars().next() else { |
| 4048 | continue; |
| 4049 | }; |
| 4050 | |
| 4051 | match kind { |
| 4052 | 'A' => { |
| 4053 | let Some(path) = parts.next() else { continue }; |
| 4054 | files.push(ParsedFile { |
| 4055 | path: path.to_string(), |
| 4056 | operation: FileOperation::Added, |
| 4057 | new_content: get_file_content(git_repo, tree, path).ok(), |
| 4058 | old_content: None, |
| 4059 | diff_lines: None, |
| 4060 | old_path: None, |
| 4061 | }); |
| 4062 | } |
| 4063 | 'M' => { |
no test coverage detected