MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / forecast_commit_kind

Function forecast_commit_kind

atomic-cli/src/commands/git/parallel.rs:8365–8388  ·  view source on GitHub ↗

Classify an incoming git commit for the `--dry-run` forecast (SPEC §4.4). `records_present(hash)` reports whether a named original change hash exists locally; callers wire it to `Repository::has_change`.

(
    message: &str,
    is_merge: bool,
    records_present: impl Fn(&str) -> bool,
)

Source from the content-addressed store, hash-verified

8363/// `records_present(hash)` reports whether a named original change hash exists
8364/// locally; callers wire it to `Repository::has_change`.
8365pub(crate) fn forecast_commit_kind(
8366 message: &str,
8367 is_merge: bool,
8368 records_present: impl Fn(&str) -> bool,
8369) -> ForecastKind {
8370 if is_merge {
8371 return ForecastKind::Merge;
8372 }
8373 match parse_atomic_changes_trailer(message) {
8374 Some(hashes) => {
8375 if hashes.iter().all(|h| records_present(h)) {
8376 ForecastKind::SquashInsertable {
8377 count: hashes.len(),
8378 pr: parse_pr_number(message),
8379 }
8380 } else {
8381 ForecastKind::SquashRecordsMissing {
8382 count: hashes.len(),
8383 }
8384 }
8385 }
8386 None => ForecastKind::Normal,
8387 }
8388}
8389
8390/// Remove change refs a failed squash-insert added to `view`, newest first, so
8391/// a divergent or partial insert leaves the shared view exactly as it was

Callers 1

Calls 5

parse_pr_numberFunction · 0.85
allMethod · 0.45
iterMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected