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

Function change

atomic-cli/src/commands/rpc.rs:2289–2426  ·  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

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

Callers 1

runMethod · 0.50

Calls 15

decode_change_ledgerFunction · 0.85
MerkleClass · 0.85
as_refMethod · 0.80
print_changeMethod · 0.80
openFunction · 0.50
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