Skip to main content

write

Function write 

Source
pub fn write(root: &Path, to: &str) -> Result<Vec<String>>
Expand description

Write to into the one place the version is authored, keep the lock’s record of it in step, and say which files changed.

Byte-exact and narrow: the manifest’s version line inside [package], and the version line of the lock’s own majordomus-cli entry — the one line cargo would rewrite. Nothing else in either file is read or rewritten, so a dependency at the same version is untouched. PROJECTION, the generator stamps and the changelog are not written here: they are derived, and scripts/derive derives them.

use majordomus_cli::release::version::{declared, write, MANIFEST};
let dir = tempfile::tempdir().unwrap();
std::fs::create_dir_all(dir.path().join("apps/majordomus-cli")).unwrap();
std::fs::write(dir.path().join(MANIFEST), "[package]\nversion = \"0.8.0\"\n").unwrap();
assert_eq!(write(dir.path(), "0.9.0").unwrap(), vec![MANIFEST.to_string()]);
assert_eq!(declared(dir.path()).as_deref(), Some("0.9.0"));