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

Method get_latest_change

atomic-cli/src/commands/change/command.rs:284–306  ·  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

282
283 /// Get the most recent change on the view.
284 fn get_latest_change(&self, repo: &Repository, view_name: &str) -> CliResult<(Hash, u64)> {
285 let txn = repo
286 .pristine()
287 .read_txn()
288 .map_err(|e| CliError::Internal(anyhow::anyhow!("{}", e)))?;
289
290 let view = txn
291 .get_view(view_name)
292 .map_err(|e| CliError::Internal(anyhow::anyhow!("{}", e)))?
293 .ok_or_else(|| CliError::ViewNotFound {
294 name: view_name.to_string(),
295 })?;
296
297 if view.change_count == 0 {
298 return Err(CliError::NothingToRecord);
299 }
300
301 let seq = view.change_count - 1;
302 let entry = get_change_at_sequence(&txn, &view, seq)
303 .map_err(|e| CliError::Internal(anyhow::anyhow!("{}", e)))?;
304
305 Ok((entry.hash, seq))
306 }
307
308 /// Format the change for default output.
309 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