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

Method get_latest_change

atomic-cli/src/commands/change/command.rs:300–322  ·  view source on GitHub ↗

Get the most recent change on the view.

(&self, repo: &Repository, view_name: &str)

Source from the content-addressed store, hash-verified

298
299 /// Get the most recent change on the view.
300 fn get_latest_change(&self, repo: &Repository, view_name: &str) -> CliResult<(Hash, u64)> {
301 let txn = repo
302 .pristine()
303 .read_txn()
304 .map_err(|e| CliError::Internal(anyhow::anyhow!("{}", e)))?;
305
306 let view = txn
307 .get_view(view_name)
308 .map_err(|e| CliError::Internal(anyhow::anyhow!("{}", e)))?
309 .ok_or_else(|| CliError::ViewNotFound {
310 name: view_name.to_string(),
311 })?;
312
313 if view.change_count == 0 {
314 return Err(CliError::NothingToRecord);
315 }
316
317 let seq = view.change_count - 1;
318 let entry = get_change_at_sequence(&txn, &view, seq)
319 .map_err(|e| CliError::Internal(anyhow::anyhow!("{}", e)))?;
320
321 Ok((entry.hash, seq))
322 }
323
324 /// Format the change for default output.
325 fn format_default(

Callers 1

resolve_identifierMethod · 0.80

Calls 4

read_txnMethod · 0.80
pristineMethod · 0.80
get_change_at_sequenceFunction · 0.50
get_viewMethod · 0.45

Tested by

no test coverage detected