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:3888–3998  ·  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

3886}
3887
3888fn parse_diff_files_via_git_cli(
3889 git_repo: &GitRepository,
3890 commit_oid: Oid,
3891 parent_oid: Oid,
3892 tree: &Tree<'_>,
3893 parent_tree: &Tree<'_>,
3894) -> CliResult<Vec<ParsedFile>> {
3895 let repo_root = git_repo.path().parent().ok_or_else(|| CliError::GitError {
3896 message: "Failed to locate git repository root".to_string(),
3897 })?;
3898
3899 let output = Command::new("git")
3900 .arg("-C")
3901 .arg(repo_root)
3902 .arg("diff-tree")
3903 .arg("-r")
3904 .arg("--name-status")
3905 .arg("-M")
3906 .arg(parent_oid.to_string())
3907 .arg(commit_oid.to_string())
3908 .output()
3909 .map_err(|e| CliError::GitError {
3910 message: format!("Failed to run git diff-tree fallback: {}", e),
3911 })?;
3912
3913 if !output.status.success() {
3914 return Err(CliError::GitError {
3915 message: format!(
3916 "git diff-tree fallback failed: {}",
3917 String::from_utf8_lossy(&output.stderr).trim()
3918 ),
3919 });
3920 }
3921
3922 let mut files = Vec::new();
3923 for line in String::from_utf8_lossy(&output.stdout).lines() {
3924 if line.is_empty() {
3925 continue;
3926 }
3927 let mut parts = line.split('\t');
3928 let status = parts.next().unwrap_or_default();
3929 let Some(kind) = status.chars().next() else {
3930 continue;
3931 };
3932
3933 match kind {
3934 'A' => {
3935 let Some(path) = parts.next() else { continue };
3936 files.push(ParsedFile {
3937 path: path.to_string(),
3938 operation: FileOperation::Added,
3939 new_content: get_file_content(git_repo, tree, path).ok(),
3940 old_content: None,
3941 diff_lines: None,
3942 old_path: None,
3943 });
3944 }
3945 '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