MCPcopy Create free account
hub / github.com/concensure/Semantic / parse_hunk_header

Function parse_hunk_header

patch_engine/src/lib.rs:260–275  ·  view source on GitHub ↗
(line: &str)

Source from the content-addressed store, hash-verified

258}
259
260fn parse_hunk_header(line: &str) -> Result<Option<(usize, usize, usize, usize)>> {
261 if !line.starts_with("@@ ") || !line.ends_with(" @@") {
262 return Ok(None);
263 }
264 let body = &line[3..line.len() - 3];
265 let mut parts = body.split_whitespace();
266 let old_part = parts
267 .next()
268 .ok_or_else(|| anyhow!("missing old hunk range"))?;
269 let new_part = parts
270 .next()
271 .ok_or_else(|| anyhow!("missing new hunk range"))?;
272 let (old_start, old_len) = parse_hunk_range(old_part, '-')?;
273 let (new_start, new_len) = parse_hunk_range(new_part, '+')?;
274 Ok(Some((old_start, old_len, new_start, new_len)))
275}
276
277fn parse_hunk_range(value: &str, prefix: char) -> Result<(usize, usize)> {
278 let trimmed = value

Callers 1

apply_unified_diffFunction · 0.85

Calls 1

parse_hunk_rangeFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…