fix: remove panics and unblock flows
Rust / build (macos-latest, stable) (push) Canceled after 0s
Rust / build (ubuntu-latest, stable) (push) Canceled after 0s
Rust / build (windows-latest, stable) (push) Canceled after 0s

This commit is contained in:
2026-11-25 03:20:40 +07:00
parent 0fd8ea12fb
commit 3f64b36ff4
52 changed files with 753 additions and 567 deletions
+10 -1
View File
@@ -271,11 +271,20 @@ impl ConsumeHunk for PatchCollector {
GixLineKind::Remove => '-',
GixLineKind::Add => '+',
};
// Tokens may already carry the line's newline; emit exactly one.
let content = content.strip_suffix(b"\n").unwrap_or(content);
let (content, terminated) = match content.strip_suffix(b"\n") {
Some(rest) => (rest, true),
None => (*content, false),
};
self.text.push(prefix);
self.text.push_str(&String::from_utf8_lossy(content));
self.text.push('\n');
if !terminated {
self.text.push_str("\\ No newline at end of file\n");
}
}
Ok(())