Skip to main content

decide_adding

Function decide_adding 

Source
pub fn decide_adding(
    trunk: Version,
    observed: Impact,
    policy: &ReleasePolicy,
    changed: &[String],
    added: &[String],
) -> LandingDecision
Expand description

decide for a change that also says which of its changed paths it added: the record of the trunk’s release lands at that release’s number only when the change adds it. decide knows of no added path, so it never grants that.

use majordomus_cli::release::compat::Impact;
use majordomus_cli::release::landing::{decide_adding, Allocation, ReleasePolicy};
use majordomus_cli::release::version::Version;

let policy = ReleasePolicy {
    allocation: Allocation::Landing,
    floor: Impact::Minor,
    exempt: vec![],
};
let trunk = Version::parse("0.20.0").unwrap();
let changed = [
    ".ai/repo/releases/v0.20.0.yaml".to_string(),
    "docs/INSTALL.md".to_string(),
];
// the record pull request adds the record, and lands at the release's number
let d = decide_adding(trunk, Impact::None, &policy, &changed, &changed[..1]);
assert_eq!(d.next_version, "0.20.0");
// a change that edits the record already written owes the floor
let d = decide_adding(trunk, Impact::None, &policy, &changed, &[]);
assert_eq!(d.next_version, "0.21.0");