Skip to main content

decide

Function decide 

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

Decide what a landing allocates (ADR 0134 §2-4).

selected = max(required_by_compatibility, floor), where an exemption covering every changed path sets the floor to none and never touches the requirement.

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

let policy = ReleasePolicy {
    allocation: Allocation::Landing,
    floor: Impact::Minor,
    exempt: vec![ReleaseExemption {
        id: "plan-records".into(),
        description: "plan records change no product behaviour".into(),
        paths: vec![".ai/repo/project/**".into()],
    }],
};
let trunk = Version::parse("0.20.0").unwrap();
// a plan record alone is exempt from the floor, and so allocates nothing
let d = decide(trunk, Impact::None, &policy, &[".ai/repo/project/issues/I9.yaml".into()]);
assert_eq!(d.next_version, "0.20.0");
assert_eq!(d.exemption.unwrap().id, "plan-records");
// a breaking change below 1.0.0 costs a minor, which the floor already asks
let d = decide(trunk, Impact::Major, &policy, &["src/a.rs".into()]);
assert_eq!(d.next_version, "0.21.0");