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

Function change

atomic-cli/src/commands/rpc.rs:2288–2425  ·  view source on GitHub ↗

`atomic change` over GetChange (includes.metadata: the versioned change bundle + the provenance ledger). The full-detail renders — the Change Ledger, hunks, JSON — run client-side over the wire data with the SAME formatters the local path uses: one render, two data sources.

(args: &super::change::command::ChangeCmd)

Source from the content-addressed store, hash-verified

2286/// Change Ledger, hunks, JSON — run client-side over the wire data with
2287/// the SAME formatters the local path uses: one render, two data sources.
2288pub fn change(args: &super::change::command::ChangeCmd) -> CliResult<bool> {
2289 use super::change::command::ChangeRenderData;
2290 use super::change::types::ChangeIdentifier;
2291 let Some(session) = Service::open()? else {
2292 return Ok(false);
2293 };
2294
2295 // Resolve the identifier: None = "latest" (the view's newest change,
2296 // via Log); a full hash or a view sequence ride the ChangeRef; a
2297 // prefix rides the wire's prefix arm (whole-store resolution).
2298 let reference = match args.identifier.as_deref() {
2299 None => {
2300 let entries = session.log(pb::LogRequest {
2301 repository: Some(session.reference.clone()),
2302 all_views: false,
2303 view: args.view.clone(),
2304 cursor: None,
2305 budget: Some(pb::PageBudget {
2306 max_items: Some(1),
2307 max_bytes: None,
2308 }),
2309 path_filter: Vec::new(),
2310 tags_only: false,
2311 })?;
2312 let Some(entry) = entries.entries.first() else {
2313 return Err(CliError::ChangeNotFound {
2314 hash: "latest".to_string(),
2315 });
2316 };
2317 let hash = entry
2318 .hash
2319 .clone()
2320 .ok_or_else(|| CliError::Internal(anyhow::anyhow!("log entry carries no hash")))?;
2321 pb::ChangeRef {
2322 kind: Some(pb::change_ref::Kind::Hash(hash)),
2323 }
2324 }
2325 Some(identifier) => {
2326 let parsed = ChangeIdentifier::parse(Some(identifier))
2327 .map_err(|error| CliError::InvalidArgument { message: error })?;
2328 match parsed {
2329 ChangeIdentifier::FullHash(hash) => {
2330 let mut bytes = [0u8; 32];
2331 bytes.copy_from_slice(&hash.0);
2332 pb::ChangeRef {
2333 kind: Some(pb::change_ref::Kind::Hash(pb::Hash {
2334 value: bytes.to_vec(),
2335 algorithm: pb::HashAlgorithm::Blake3 as i32,
2336 })),
2337 }
2338 }
2339 ChangeIdentifier::Sequence(sequence) => pb::ChangeRef {
2340 kind: Some(pb::change_ref::Kind::Sequence(sequence)),
2341 },
2342 _ => pb::ChangeRef {
2343 kind: Some(pb::change_ref::Kind::Prefix(identifier.to_string())),
2344 },
2345 }

Callers 1

runMethod · 0.50

Calls 15

openFunction · 0.85
decode_change_ledgerFunction · 0.85
MerkleClass · 0.85
as_refMethod · 0.80
print_changeMethod · 0.80
parseFunction · 0.50
deserializeFunction · 0.50
logMethod · 0.45
cloneMethod · 0.45
get_changeMethod · 0.45
as_sliceMethod · 0.45
okMethod · 0.45

Tested by

no test coverage detected