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)
| 395 | /// `Atomic-State`. This lets us determine which atomic changes were |
| 396 | /// already pushed. |
| 397 | fn find_last_pushed_state(&self, git_repo: &GitRepository, view: &str) -> Option<Merkle> { |
| 398 | let mut commit = git_repo.head().ok()?.peel_to_commit().ok()?; |
| 399 | for _ in 0..1000 { |
| 400 | let message = commit.message().unwrap_or(""); |
| 401 | let commit_view = parse_trailer(message, "Atomic-View"); |
| 402 | if commit_view.as_deref() == Some(view) { |
| 403 | if let Some(state) = parse_trailer(message, "Atomic-State") |
| 404 | .and_then(|s| Merkle::from_base32(s.as_bytes())) |
| 405 | { |
| 406 | return Some(state); |
| 407 | } |
| 408 | } |
| 409 | commit = match commit.parent(0) { |
| 410 | Ok(p) => p, |
| 411 | Err(_) => break, |
| 412 | }; |
| 413 | } |
| 414 | None |
| 415 | } |
| 416 | |
| 417 | /// Resolve the git branch this push targets, applying draft-view |
| 418 | /// auto-mapping. |
no test coverage detected