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

Method get_latest_change

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

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