MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / parse_diff_files_via_git_cli

Function parse_diff_files_via_git_cli

atomic-cli/src/commands/git/parallel.rs:4006–4116  ·  view source on GitHub ↗
(
    git_repo: &GitRepository,
    commit_oid: Oid,
    parent_oid: Oid,
    tree: &Tree<'_>,
    parent_tree: &Tree<'_>,
)

Source from the content-addressed store, hash-verified

4004}
4005
4006fn 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' => {

Callers 1

parse_commitFunction · 0.85

Calls 8

get_file_contentFunction · 0.85
parentMethod · 0.80
successMethod · 0.80
pathMethod · 0.45
linesMethod · 0.45
is_emptyMethod · 0.45
nextMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected