extract_file_paths_from_git_diff

Function extract_file_paths_from_git_diff 

Source
pub fn extract_file_paths_from_git_diff(
    text: &str,
    allow_tests: bool,
) -> Vec<(PathBuf, Option<usize>, Option<usize>, Option<String>, Option<HashSet<usize>>)>
Expand description

Extract file paths from git diff format

This function takes a string of text in git diff format and extracts file paths with line ranges. It’s used when the extract command is run with the –diff option.

The function looks for patterns like:

  • diff –git a/path/to/file.rs b/path/to/file.rs
  • @@ -45,7 +45,7 @@ (hunk header)

It extracts the file path from the diff header and the line range from the hunk header. We don’t add arbitrary context lines - instead we rely on the AST parser to find the full function or code block that contains the changed lines.

If allow_tests is false, test files will be filtered out.