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. `repair_index` controls the best-effort Git SHA index repair. Real imports pass `tru
(
&self,
repo: &Repository,
view_name: &str,
repair_index: bool,
)
| 281 | /// imports pass `true`; the `--dry-run` forecast passes `false` so it can |
| 282 | /// compute markers against a read-only handle without writing anything. |
| 283 | fn get_incremental_markers( |
| 284 | &self, |
| 285 | repo: &Repository, |
| 286 | view_name: &str, |
| 287 | repair_index: bool, |
| 288 | ) -> CliResult<(HashSet<String>, HashSet<atomic_core::types::Merkle>)> { |
| 289 | use atomic_repository::HistoryOptions; |
| 290 | |
| 291 | let mut shas = HashSet::new(); |
| 292 | let mut states = HashSet::new(); |
| 293 | let mut index_repairs = Vec::new(); |
| 294 | |
| 295 | // Query the explicit target instead of the current view. Agent drafts |
| 296 | // intentionally hide inherited changes from their default log, so |
| 297 | // scanning the current draft makes already-imported parent commits look |
| 298 | // new and duplicates them onto the Git branch view. |
| 299 | let options = HistoryOptions::default() |
| 300 | .view(view_name) |
| 301 | .include_inherited(true); |
| 302 | let entries = repo |
| 303 | .log(options) |
| 304 | .map_err(|error| CliError::Internal(error.into()))?; |
| 305 | for entry in entries { |
| 306 | states.insert(entry.state); |
| 307 | let change = repo |
| 308 | .load_change(&entry.hash) |
| 309 | .map_err(|error| CliError::Internal(error.into()))?; |
| 310 | if let Some(ref unhashed) = change.unhashed { |
| 311 | if let Some(git) = unhashed.get("git") { |
| 312 | if let Some(sha) = git.get("sha").and_then(|v| v.as_str()) { |
| 313 | if shas.insert(sha.to_string()) { |
| 314 | index_repairs.push((sha.to_string(), entry.hash)); |
| 315 | } |
| 316 | } |
| 317 | } |
| 318 | } |
| 319 | } |
| 320 | |
| 321 | // Inserted squashes (SPEC §4) write no change record, so their git SHA |
| 322 | // isn't reachable via change `unhashed` metadata. The ReviewGate tag on |
| 323 | // the target view owns that provenance — scan tags for `git.sha` so a |
| 324 | // re-import recognises the squash as already imported and skips it. |
| 325 | if let Ok(tags) = repo.list_tags_for_view(view_name) { |
| 326 | for tag in tags { |
| 327 | if let Some(sha) = tag |
| 328 | .metadata |
| 329 | .as_ref() |
| 330 | .and_then(|m| m.get("git")) |
| 331 | .and_then(|g| g.get("sha")) |
| 332 | .and_then(|v| v.as_str()) |
| 333 | { |
| 334 | shas.insert(sha.to_string()); |
| 335 | } |
| 336 | } |
| 337 | } |
| 338 | |
| 339 | // Repair the acceleration index while scanning older repositories. |
| 340 | // The explicit target-view history is authoritative; index repair is |
no test coverage detected