(
repo: &Repository,
change: &Change,
hash: &Hash,
view: &str,
)
| 15 | const MAX_CALLERS: usize = 30; |
| 16 | |
| 17 | pub(super) fn project( |
| 18 | repo: &Repository, |
| 19 | change: &Change, |
| 20 | hash: &Hash, |
| 21 | view: &str, |
| 22 | ) -> ChangeBlastRadius { |
| 23 | let mut paths = atomic_repository::get_files_in_change(change); |
| 24 | paths.extend(change.file_ops().iter().map(|op| op.path().to_string())); |
| 25 | paths.sort(); |
| 26 | paths.dedup(); |
| 27 | let mut warnings = Vec::new(); |
| 28 | if paths.len() > MAX_FILES { |
| 29 | warnings |
| 30 | .push("Direct paths exceed the 2000-file analysis limit; coverage is partial.".into()); |
| 31 | } |
| 32 | paths.truncate(MAX_FILES); |
| 33 | let mut files: BTreeMap<String, u32> = paths.iter().cloned().map(|path| (path, 1)).collect(); |
| 34 | let mut links = BTreeSet::new(); |
| 35 | let mut registry = ParserRegistry::new(); |
| 36 | let mut analyzed = 0; |
| 37 | let mut public_change = false; |
| 38 | let mut syntax = None; |
| 39 | for (index, path) in paths.into_iter().enumerate() { |
| 40 | if index >= 100 { |
| 41 | warnings.push("Structural analysis limited to 100 direct files; remaining direct paths are retained.".into()); |
| 42 | break; |
| 43 | } |
| 44 | if !registry.is_supported(&path) { |
| 45 | warnings.push(format!("{path}: no structural parser; direct impact only.")); |
| 46 | continue; |
| 47 | } |
| 48 | let before = repo.get_file_content_before_change_on_view(&path, hash, view); |
| 49 | let after = repo.get_file_content_after_change_on_view(&path, hash, view); |
| 50 | let (Ok(before), Ok(after)) = (before, after) else { |
| 51 | warnings.push(format!("{path}: historical content reconstruction failed.")); |
| 52 | continue; |
| 53 | }; |
| 54 | if before.is_none() && after.is_none() { |
| 55 | warnings.push(format!("{path}: historical content unavailable.")); |
| 56 | continue; |
| 57 | } |
| 58 | if before.is_none() && !change.hunks().iter().any(|op| matches!(op, atomic_core::change::GraphOp::FileAdd { path: added, .. } if added == &path)) { |
| 59 | warnings.push(format!("{path}: before-content missing without a file-add operation.")); |
| 60 | } |
| 61 | if after.is_none() && !change.hunks().iter().any(|op| matches!(op, atomic_core::change::GraphOp::FileDel { path: deleted, .. } if deleted == &path)) { |
| 62 | warnings.push(format!("{path}: after-content missing without a file-delete operation.")); |
| 63 | } |
| 64 | let before = before.unwrap_or_default(); |
| 65 | let after = after.unwrap_or_default(); |
| 66 | if before.len() + after.len() > MAX_SOURCE_BYTES { |
| 67 | warnings.push(format!("{path}: source exceeds the 2 MiB analysis limit.")); |
| 68 | continue; |
| 69 | } |
| 70 | let (Ok(before), Ok(after)) = (std::str::from_utf8(&before), std::str::from_utf8(&after)) |
| 71 | else { |
| 72 | warnings.push(format!( |
| 73 | "{path}: binary/non-UTF-8 source; direct impact only." |
| 74 | )); |
no test coverage detected