pub struct Diff {
paths: Vec<String>,
}
impl Diff {
pub(crate) fn from(d: git2::Diff) -> Self {
Self {
paths: d.deltas().fold(vec![], |mut vec, delta| {
append(&mut vec, delta.old_file());
append(&mut vec, delta.new_file());
vec
}),
}
}
pub fn get_paths(&self) -> Vec<String> {
self.paths.clone()
}
}
fn append(vec: &mut Vec<String>, f: git2::DiffFile) {
if let Some(path) = f.path().map(|p| p.to_str().unwrap().into()) {
vec.push(path);
}
}