MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / load_graphs

Function load_graphs

atomic-repository/src/triage/report.rs:1323–1345  ·  view source on GitHub ↗

Load a change's provenance graphs: REV_DEPS-backed lookup, with a disk-scan fallback when REV_DEPS registration missed the change. Errors if no graph explains the change.

(
    repo: &Repository,
    change_hash: &Hash,
)

Source from the content-addressed store, hash-verified

1321/// disk-scan fallback when REV_DEPS registration missed the change.
1322/// Errors if no graph explains the change.
1323pub(crate) fn load_graphs(
1324 repo: &Repository,
1325 change_hash: &Hash,
1326) -> Result<Vec<(Hash, ProvenanceGraph)>, RepositoryError> {
1327 let mut graphs = repo.find_provenance_for_change(change_hash)?;
1328 if graphs.is_empty() {
1329 graphs = repo.find_provenance_for_change_scan(change_hash)?;
1330 }
1331 if graphs.is_empty() {
1332 return Err(RepositoryError::InvalidOperation {
1333 message: format!(
1334 "no provenance graph explains change {}",
1335 change_hash.to_base32()
1336 ),
1337 });
1338 }
1339 // Most-recent first (a change explained by >1 graph shows all; the newest
1340 // leads). Both loaders sort/return unspecified order, so sort here.
1341 graphs.sort_by_key(|(_, g)| {
1342 std::cmp::Reverse(atomic_core::types::timestamp::epoch_millis(g.timestamp))
1343 });
1344 Ok(graphs)
1345}
1346
1347#[cfg(test)]
1348mod tests {

Callers 1

load_provenance_compactFunction · 0.70

Calls 4

epoch_millisFunction · 0.85
is_emptyMethod · 0.45

Tested by

no test coverage detected