MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / stale_files_since_commit

Method stale_files_since_commit

src/tracedecay/indexing.rs:1220–1294  ·  view source on GitHub ↗

Computes the repo-relative paths changed between `base_commit` and the current git HEAD via a gix tree diff (both directions, including deletions), for diff-scoped incremental syncs by the watcher. Returns: - `Some(paths)` (forward-slash normalized) on a successful bounded diff; - `None` when `base_commit` is missing/unreachable (force-push, gc) — the caller must fall back to a full [`find_stale_

(
        &self,
        base_commit: &str,
        escalation_limit: usize,
    )

Source from the content-addressed store, hash-verified

1218 ///
1219 /// Does not touch the DB; the watcher wires it into `sync_if_stale_silent`.
1220 pub fn stale_files_since_commit(
1221 &self,
1222 base_commit: &str,
1223 escalation_limit: usize,
1224 ) -> Option<Vec<String>> {
1225 let repo = gix::open(&self.project_root).ok()?;
1226
1227 let base_tree = repo
1228 .rev_parse_single(base_commit)
1229 .ok()?
1230 .object()
1231 .ok()?
1232 .peel_to_tree()
1233 .ok()?;
1234
1235 let head_tree = repo.head_commit().ok()?.tree().ok()?;
1236
1237 let mut changed: HashSet<String> = HashSet::new();
1238 base_tree
1239 .changes()
1240 .ok()?
1241 .for_each_to_obtain_tree(&head_tree, |change| {
1242 use gix::object::tree::diff::Change;
1243 {
1244 let mut push = |loc: &gix::bstr::BStr, mode: &gix::object::tree::EntryMode| {
1245 if !mode.is_tree() {
1246 changed.insert(loc.to_string());
1247 }
1248 };
1249 match &change {
1250 Change::Addition {
1251 location,
1252 entry_mode,
1253 ..
1254 }
1255 | Change::Modification {
1256 location,
1257 entry_mode,
1258 ..
1259 }
1260 | Change::Deletion {
1261 location,
1262 entry_mode,
1263 ..
1264 } => push(location, entry_mode),
1265 Change::Rewrite {
1266 source_location,
1267 source_entry_mode,
1268 location,
1269 entry_mode,
1270 ..
1271 } => {
1272 push(source_location, source_entry_mode);
1273 push(location, entry_mode);
1274 }
1275 }
1276 }
1277 // Stop early once the change set is clearly a full-sync case;

Callers 5

sync_projectFunction · 0.80
watcher_syncFunction · 0.80

Calls 4

pushFunction · 0.85
normalize_rel_pathsFunction · 0.85
insertMethod · 0.80
collectMethod · 0.80