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

Method get_latest_change

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

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