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

Function load_graphs

atomic-cli/src/commands/provenance/command.rs:148–169  ·  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

146/// fallback when REV_DEPS registration missed the change. Errors if no graph
147/// explains the change.
148fn load_graphs(repo: &Repository, change_hash: &Hash) -> CliResult<Vec<(Hash, ProvenanceGraph)>> {
149 let mut graphs = repo
150 .find_provenance_for_change(change_hash)
151 .map_err(CliError::Repository)?;
152 if graphs.is_empty() {
153 graphs = repo
154 .find_provenance_for_change_scan(change_hash)
155 .map_err(CliError::Repository)?;
156 }
157 if graphs.is_empty() {
158 return Err(CliError::InvalidArgument {
159 message: format!(
160 "no provenance graph explains change {}",
161 change_hash.to_base32()
162 ),
163 });
164 }
165 // Most-recent first (a change explained by >1 graph shows all; the newest
166 // leads). Both loaders sort/return unspecified order, so sort here.
167 graphs.sort_by_key(|(_, g)| std::cmp::Reverse(g.timestamp));
168 Ok(graphs)
169}
170
171/// Resolve the CLI target (bare hash, hash prefix, or `urn:atomic:change:<b32>`)
172/// to a change `Hash`.

Callers 1

runMethod · 0.85

Calls 3

is_emptyMethod · 0.45

Tested by

no test coverage detected