cli: Refactor git diff encoding

Move code for writing radicle_surf diff's in git's unified diff format
into its own module.  Lean on the type system by defining a
`UnifiedDiff` trait to provide a method `encode` to encode to the
format and another default method to convert to a git 'unified' diff
string.

Additionally a `Header` struct is added to support processing Unified
Diff files.  The Header's line numbers must be tracked and modified to
produce legal diff files.

This is in preparation for DDiff support.  Upcoming improvements will
include parse unified diff's into these types to support test data.
This commit is contained in:
Slack Coder
2023-08-04 12:45:53 +02:00
committed by cloudhead
parent 6ed3ab914d
commit 0141313b35
5 changed files with 353 additions and 177 deletions
+4
View File
@@ -1,4 +1,8 @@
//! Git-related functions and types.
#[path = "git/unified_diff.rs"]
pub mod unified_diff;
use std::collections::HashSet;
use std::fmt::Display;
use std::fs::{File, OpenOptions};