Get the set of already imported Git SHAs from existing changes, plus the Merkle states already present in the import target 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,
view_name: &str,
)
| 274 | /// push`: such a commit trailers the view state it represents, and if |
| 275 | /// that state is already known the commit adds nothing. |
| 276 | fn get_incremental_markers( |
| 277 | &self, |
| 278 | repo: &Repository, |
| 279 | view_name: &str, |
| 280 | ) -> CliResult<(HashSet<String>, HashSet<atomic_core::types::Merkle>)> { |
| 281 | use atomic_repository::HistoryOptions; |
| 282 | |
| 283 | let mut shas = HashSet::new(); |
| 284 | let mut states = HashSet::new(); |
| 285 | let mut index_repairs = Vec::new(); |
| 286 | |
| 287 | // Query the explicit target instead of the current view. Agent drafts |
| 288 | // intentionally hide inherited changes from their default log, so |
| 289 | // scanning the current draft makes already-imported parent commits look |
| 290 | // new and duplicates them onto the Git branch view. |
| 291 | let options = HistoryOptions::default() |
| 292 | .view(view_name) |
| 293 | .include_inherited(true); |
| 294 | let entries = repo |
| 295 | .log(options) |
| 296 | .map_err(|error| CliError::Internal(error.into()))?; |
| 297 | for entry in entries { |
| 298 | states.insert(entry.state); |
| 299 | let change = repo |
| 300 | .load_change(&entry.hash) |
| 301 | .map_err(|error| CliError::Internal(error.into()))?; |
| 302 | if let Some(ref unhashed) = change.unhashed { |
| 303 | if let Some(git) = unhashed.get("git") { |
| 304 | if let Some(sha) = git.get("sha").and_then(|v| v.as_str()) { |
| 305 | if shas.insert(sha.to_string()) { |
| 306 | index_repairs.push((sha.to_string(), entry.hash)); |
| 307 | } |
| 308 | } |
| 309 | } |
| 310 | } |
| 311 | } |
| 312 | |
| 313 | // Repair the acceleration index while scanning older repositories. |
| 314 | // The explicit target-view history is authoritative; index repair is |
| 315 | // best-effort and batched so a no-op sync never commits once per |
| 316 | // historical Git change. |
| 317 | if let Err(error) = repo.index_git_shas(&index_repairs) { |
| 318 | log::warn!( |
| 319 | "Failed to repair Git SHA index for view '{}': {}", |
| 320 | view_name, |
| 321 | error |
| 322 | ); |
| 323 | } |
| 324 | |
| 325 | Ok((shas, states)) |
| 326 | } |
| 327 | |
| 328 | /// Get all local branch names. |
| 329 | fn get_all_branches(&self, git_repo: &GitRepository) -> CliResult<Vec<String>> { |
no test coverage detected