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:609–627  ·  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

607 /// `Atomic-State`. This lets us determine which atomic changes were
608 /// already pushed.
609 fn find_last_pushed_state(&self, git_repo: &GitRepository, view: &str) -> Option<Merkle> {
610 let mut commit = git_repo.head().ok()?.peel_to_commit().ok()?;
611 for _ in 0..1000 {
612 let message = commit.message().unwrap_or("");
613 let commit_view = parse_trailer(message, "Atomic-View");
614 if commit_view.as_deref() == Some(view) {
615 if let Some(state) = parse_trailer(message, "Atomic-State")
616 .and_then(|s| Merkle::from_base32(s.as_bytes()))
617 {
618 return Some(state);
619 }
620 }
621 commit = match commit.parent(0) {
622 Ok(p) => p,
623 Err(_) => break,
624 };
625 }
626 None
627 }
628
629 /// Resolve the git branch this push targets, applying draft-view
630 /// auto-mapping.

Callers 1

runMethod · 0.80

Calls 6

parentMethod · 0.80
parse_trailerFunction · 0.70
okMethod · 0.45
headMethod · 0.45
messageMethod · 0.45
as_bytesMethod · 0.45

Tested by

no test coverage detected