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