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

Method find_last_pushed_state

atomic-cli/src/commands/git/push.rs:354–372  ·  view source on GitHub ↗

Walk git history (first-parent mainline) to find the most recent commit whose `Atomic-View` trailer matches `view` and return its `Atomic-State`. This lets us determine which atomic changes were already pushed.

(&self, git_repo: &GitRepository, view: &str)

Source from the content-addressed store, hash-verified

352 /// `Atomic-State`. This lets us determine which atomic changes were
353 /// already pushed.
354 fn find_last_pushed_state(&self, git_repo: &GitRepository, view: &str) -> Option<Merkle> {
355 let mut commit = git_repo.head().ok()?.peel_to_commit().ok()?;
356 for _ in 0..1000 {
357 let message = commit.message().unwrap_or("");
358 let commit_view = parse_trailer(message, "Atomic-View");
359 if commit_view.as_deref() == Some(view) {
360 if let Some(state) = parse_trailer(message, "Atomic-State")
361 .and_then(|s| Merkle::from_base32(s.as_bytes()))
362 {
363 return Some(state);
364 }
365 }
366 commit = match commit.parent(0) {
367 Ok(p) => p,
368 Err(_) => break,
369 };
370 }
371 None
372 }
373
374 /// Resolve the git branch this push targets, applying draft-view
375 /// auto-mapping.

Callers 1

runMethod · 0.80

Calls 4

parse_trailerFunction · 0.85
parentMethod · 0.80
messageMethod · 0.45
as_bytesMethod · 0.45

Tested by

no test coverage detected