pub fn decide(
last: Option<&str>,
bump: Bump,
contract: Result<String, String>,
) -> (Option<String>, DecidedBy, Option<String>)Expand description
Who answers next, and with what: the contract when it could be measured, and no one
when it could not.
contract is the analysis’ measured version ([crate::release::compat::VersionPlan:: measured_version]), or why none could be measured. ADR 0051 refuses an unmeasurable
baseline rather than guessing one, so an Err leaves next absent, [DecidedBy:: Undecided] and the reason carried — the commit inference stays evidence beside it and
never stands in for the measurement. The contract’s answer is a minimum: when it is no
greater than last — only behaviour behind the public boundary changed, so the contract
requires no release — it is the release already made, never the next one. Then the
commits decide whether anything is released at all, and the contract decides how much:
the smallest release above the last, a patch, labelled DecidedBy::ContractAndCommits.
The commits never raise next beyond what the contract requires.
use majordomus_cli::release::model::DecidedBy;
use majordomus_cli::release::version::{decide, Bump};
// the commits say BREAKING, the contract only grew: below 1.0 that owes a minor
let (next, by, why) = decide(Some("0.10.0"), Bump::Major, Ok("0.11.0".into()));
assert_eq!((next.as_deref(), by, why), (Some("0.11.0"), DecidedBy::Contract, None));
// only fixes, the surface unchanged: the contract's minimum is the release already made
let (next, by, _) = decide(Some("0.10.0"), Bump::Patch, Ok("0.10.0".into()));
assert_eq!((next.as_deref(), by), (Some("0.10.1"), DecidedBy::ContractAndCommits));
// no published baseline: no one decides, and the reason is carried
let (next, by, why) = decide(None, Bump::Minor, Err("no release".into()));
assert_eq!((next, by), (None, DecidedBy::Undecided));
assert_eq!(why.as_deref(), Some("no release"));