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)
| 326 | /// `Atomic-State`. This lets us determine which atomic changes were |
| 327 | /// already pushed. |
| 328 | fn find_last_pushed_state(&self, git_repo: &GitRepository, view: &str) -> Option<Merkle> { |
| 329 | let mut commit = git_repo.head().ok()?.peel_to_commit().ok()?; |
| 330 | for _ in 0..1000 { |
| 331 | let message = commit.message().unwrap_or(""); |
| 332 | let commit_view = parse_trailer(message, "Atomic-View"); |
| 333 | if commit_view.as_deref() == Some(view) { |
| 334 | if let Some(state) = parse_trailer(message, "Atomic-State") |
| 335 | .and_then(|s| Merkle::from_base32(s.as_bytes())) |
| 336 | { |
| 337 | return Some(state); |
| 338 | } |
| 339 | } |
| 340 | commit = match commit.parent(0) { |
| 341 | Ok(p) => p, |
| 342 | Err(_) => break, |
| 343 | }; |
| 344 | } |
| 345 | None |
| 346 | } |
| 347 | |
| 348 | /// The git branch the push will land on: `--branch` if given, else |
| 349 | /// the currently checked-out branch. |
no test coverage detected