Skip to main content

parse_scratchpad_diffs

Function parse_scratchpad_diffs 

Source
pub fn parse_scratchpad_diffs(raw_content: &str, worker_id: String) -> Vec<Hunk>
Expand description

Parses scratchpad diff content from .hematite_scratch files into Hunk objects.

This function scans raw XML-ish content for <patch> tags and extracts:

  • start: Starting line number (from start="..." attribute)
  • end: Ending line number (from end="..." attribute)
  • content: The patch content between <patch> and </patch>

§Arguments

  • raw_content — Raw string from scratchpad file containing patch tags
  • worker_id — Identifier of the worker processing this content

§Returns

A Vec<Hunk> with all parsed patches (stops at malformed or unclosed tags)

§Example

let xml = r#"<patch start="10" end="20">
    // Some diff content
</patch>"#;
let hunks = parse_scratchpad_diffs(xml, "worker-1".to_string());
assert_eq!(hunks[0].start_line, 10);