Skip to content

Commit

Permalink
Modify bump-version subcommand to also bump dependent packages' dep…
Browse files Browse the repository at this point in the history
…endencies
  • Loading branch information
jessebraham committed Nov 11, 2024
1 parent 4af44b1 commit 7b9444c
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions xtask/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,35 @@ pub fn bump_version(workspace: &Path, package: Package, amount: Version) -> Resu
manifest["package"]["version"] = toml_edit::value(version.to_string());
fs::write(manifest_path, manifest.to_string())?;

for pkg in Package::iter() {
if [package, Package::HilTest, Package::Examples].contains(&pkg) {
continue;
}

let manifest_path = workspace.join(pkg.to_string()).join("Cargo.toml");
let manifest = fs::read_to_string(&manifest_path)
.with_context(|| format!("Could not read {}", manifest_path.display()))?;

let mut manifest = manifest.parse::<toml_edit::DocumentMut>()?;

if manifest["dependencies"]
.as_table()
.unwrap()
.contains_key(&package.to_string())
{
log::info!(
" Bumping {package} version for package {pkg}: ({prev_version} -> {version})"
);

manifest["dependencies"].as_table_mut().map(|table| {
table[&package.to_string()]["version"] = toml_edit::value(version.to_string())
});

fs::write(&manifest_path, manifest.to_string())
.with_context(|| format!("Could not write {}", manifest_path.display()))?;
}
}

Ok(())
}

Expand Down

0 comments on commit 7b9444c

Please sign in to comment.