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

Function forecast_commit_kind

atomic-cli/src/commands/git/parallel.rs:3862–3885  ·  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

3860/// `records_present(hash)` reports whether a named original change hash exists
3861/// locally; callers wire it to `Repository::has_change`.
3862pub(crate) fn forecast_commit_kind(
3863 message: &str,
3864 is_merge: bool,
3865 records_present: impl Fn(&str) -> bool,
3866) -> ForecastKind {
3867 if is_merge {
3868 return ForecastKind::Merge;
3869 }
3870 match parse_atomic_changes_trailer(message) {
3871 Some(hashes) => {
3872 if hashes.iter().all(|h| records_present(h)) {
3873 ForecastKind::SquashInsertable {
3874 count: hashes.len(),
3875 pr: parse_pr_number(message),
3876 }
3877 } else {
3878 ForecastKind::SquashRecordsMissing {
3879 count: hashes.len(),
3880 }
3881 }
3882 }
3883 None => ForecastKind::Normal,
3884 }
3885}
3886
3887/// Remove change refs a failed squash-insert added to `view`, newest first, so
3888/// 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