Get the set of already imported Git SHAs from existing changes, plus the Merkle states already present in the current view. The states let the importer skip commits created by `atomic git push`: such a commit trailers the view state it represents, and if that state is already known the commit adds nothing.
(
&self,
repo: &Repository,
)
| 268 | /// push`: such a commit trailers the view state it represents, and if |
| 269 | /// that state is already known the commit adds nothing. |
| 270 | fn get_incremental_markers( |
| 271 | &self, |
| 272 | repo: &Repository, |
| 273 | ) -> (HashSet<String>, HashSet<atomic_core::types::Merkle>) { |
| 274 | use atomic_repository::HistoryOptions; |
| 275 | |
| 276 | // Ensure the GIT_SHA_INDEX is populated for repos imported before |
| 277 | // the index existed. This is a one-time O(n) scan that makes all |
| 278 | // subsequent --incremental runs O(1) per commit. |
| 279 | let _ = repo.backfill_git_sha_index(); |
| 280 | |
| 281 | let mut shas = HashSet::new(); |
| 282 | let mut states = HashSet::new(); |
| 283 | |
| 284 | // Iterate through all changes on the current view via log |
| 285 | let options = HistoryOptions::default(); |
| 286 | if let Ok(entries) = repo.log(options) { |
| 287 | for entry in entries { |
| 288 | states.insert(entry.state); |
| 289 | if let Ok(change) = repo.load_change(&entry.hash) { |
| 290 | if let Some(ref unhashed) = change.unhashed { |
| 291 | if let Some(git) = unhashed.get("git") { |
| 292 | if let Some(sha) = git.get("sha").and_then(|v| v.as_str()) { |
| 293 | shas.insert(sha.to_string()); |
| 294 | } |
| 295 | } |
| 296 | } |
| 297 | } |
| 298 | } |
| 299 | } |
| 300 | |
| 301 | (shas, states) |
| 302 | } |
| 303 | |
| 304 | /// Get all local branch names. |
| 305 | fn get_all_branches(&self, git_repo: &GitRepository) -> CliResult<Vec<String>> { |
no test coverage detected