Skip to main content

parse_unified_diff

Function parse_unified_diff 

Source
pub fn parse_unified_diff(
    diff_text: &str,
    project_root: Option<&PathBuf>,
) -> Result<ChangedLines>
Expand description

Parse a unified diff and extract the changed line numbers for each file

Handles standard git unified diff format:

diff --git a/file.rs b/file.rs
--- a/file.rs
+++ b/file.rs
@@ -10,3 +10,5 @@ fn example() {
 unchanged
+added line 1
+added line 2
 unchanged

§Arguments

  • diff_text - The unified diff text
  • project_root - Optional project root to resolve relative paths

§Returns

A map of file paths to the set of changed line numbers (in the new version)