use crate::{bstr::BStr, Tree};
#[derive(Clone, Copy, PartialOrd, PartialEq, Ord, Eq, Hash)]
pub enum Action {
Continue,
Cancel,
}
impl Default for Action {
fn default() -> Self {
Action::Continue
}
}
#[derive(Debug, Clone, Copy)]
pub struct Change<'a, 'old, 'new> {
pub location: &'a BStr,
pub event: change::Event<'a, 'old, 'new>,
}
pub mod change;
impl<'repo> Tree<'repo> {
#[allow(clippy::result_large_err)]
pub fn changes<'a>(&'a self) -> Result<Platform<'a, 'repo>, renames::Error> {
Ok(Platform {
state: Default::default(),
lhs: self,
tracking: None,
renames: self.repo.config.diff_renames()?.unwrap_or_default().into(),
})
}
}
#[derive(Clone)]
pub struct Platform<'a, 'repo> {
state: git_diff::tree::State,
lhs: &'a Tree<'repo>,
tracking: Option<Tracking>,
renames: Option<Renames>,
}
#[derive(Clone, Copy)]
enum Tracking {
FileName,
Path,
}
#[derive(Debug, Copy, Clone, PartialEq)]
pub struct Renames {
pub copies: Option<renames::Copies>,
pub percentage: Option<f32>,
pub limit: usize,
}
pub mod renames;
impl<'a, 'repo> Platform<'a, 'repo> {
pub fn track_filename(&mut self) -> &mut Self {
self.tracking = Some(Tracking::FileName);
self
}
pub fn track_path(&mut self) -> &mut Self {
self.tracking = Some(Tracking::Path);
self
}
pub fn track_renames(&mut self, renames: Option<Renames>) -> &mut Self {
self.renames = renames;
self
}
}
pub mod for_each;