Get the set of already imported Git SHAs from existing changes.
(&self, repo: &Repository)
| 260 | |
| 261 | /// Get the set of already imported Git SHAs from existing changes. |
| 262 | fn get_imported_shas(&self, repo: &Repository) -> HashSet<String> { |
| 263 | use atomic_repository::HistoryOptions; |
| 264 | |
| 265 | // Ensure the GIT_SHA_INDEX is populated for repos imported before |
| 266 | // the index existed. This is a one-time O(n) scan that makes all |
| 267 | // subsequent --incremental runs O(1) per commit. |
| 268 | let _ = repo.backfill_git_sha_index(); |
| 269 | |
| 270 | let mut shas = HashSet::new(); |
| 271 | |
| 272 | // Iterate through all changes on the current view via log |
| 273 | let options = HistoryOptions::default(); |
| 274 | if let Ok(entries) = repo.log(options) { |
| 275 | for entry in entries { |
| 276 | if let Ok(change) = repo.load_change(&entry.hash) { |
| 277 | if let Some(ref unhashed) = change.unhashed { |
| 278 | if let Some(git) = unhashed.get("git") { |
| 279 | if let Some(sha) = git.get("sha").and_then(|v| v.as_str()) { |
| 280 | shas.insert(sha.to_string()); |
| 281 | } |
| 282 | } |
| 283 | } |
| 284 | } |
| 285 | } |
| 286 | } |
| 287 | |
| 288 | shas |
| 289 | } |
| 290 | |
| 291 | /// Get all local branch names. |
| 292 | fn get_all_branches(&self, git_repo: &GitRepository) -> CliResult<Vec<String>> { |
no test coverage detected