use super::*;
#[derive(Debug, Clone)]
pub(crate) struct TaggedMutation {
pub(crate) session_id: String,
pub(crate) is_subagent: bool,
pub(crate) parent_session_id: String,
pub(crate) turn_index: usize,
pub(crate) line_no: usize,
pub(crate) mutation: FileMutation,
}
#[derive(Debug, Clone)]
pub(crate) struct TaggedBoundary {
pub(crate) session_id: String,
pub(crate) is_subagent: bool,
pub(crate) parent_session_id: String,
pub(crate) path: String,
pub(crate) line_no: usize,
pub(crate) turn_index: usize,
pub(crate) kind: &'static str,
pub(crate) timestamp_utc: Option<String>,
}
pub(crate) struct FileResult {
pub(crate) mutations: Vec<TaggedMutation>,
pub(crate) boundaries: Vec<TaggedBoundary>,
pub(crate) skipped_lines: usize,
pub(crate) turn_count: usize,
}
pub(crate) struct PathFilter {
pub(crate) regex: Option<Regex>,
pub(crate) glob: Option<GlobMatcher>,
}
impl PathFilter {
pub(crate) fn from_args(regex: Option<&str>, glob: Option<&str>) -> Result<Self> {
let regex = regex
.map(|re| Regex::new(re).with_context(|| format!("invalid --regex pattern: {re}")))
.transpose()?;
let glob = glob
.map(|pat| {
Glob::new(pat)
.map(|g| g.compile_matcher())
.with_context(|| format!("invalid --glob pattern: {pat}"))
})
.transpose()?;
Ok(Self { regex, glob })
}
pub(crate) fn keeps(&self, path: &str) -> bool {
if let Some(re) = &self.regex {
if !re.is_match(path) {
return false;
}
}
if let Some(g) = &self.glob {
if !g.is_match(path) {
return false;
}
}
true
}
}