Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(workspaces): report correct version update #802

Merged
merged 2 commits into from
May 31, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions crates/release_plz_core/src/command/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,17 @@ pub struct PackagesUpdate {
pub updates: Vec<(Package, UpdateResult)>,
}

impl PackagesUpdate {
pub fn set_update_result_version(&mut self, package_name: &str, version: Version) {
for (package, update) in &mut self.updates {
if package.name == package_name {
update.version = version;
return;
}
}
}
}

impl PackagesUpdate {
pub fn summary(&self) -> String {
let updates = self.updates_summary();
Expand Down Expand Up @@ -97,15 +108,15 @@ impl PackagesUpdate {
/// Update a local rust project
#[instrument]
pub fn update(input: &UpdateRequest) -> anyhow::Result<(PackagesUpdate, TempRepo)> {
let (packages_to_update, repository) = crate::next_versions(input)?;
let (mut packages_to_update, repository) = crate::next_versions(input)?;
let local_manifest_path = input.local_manifest();
let all_packages = cargo_utils::workspace_members(Some(local_manifest_path)).map_err(|e| {
anyhow!(
"cannot read workspace members in manifest {:?}: {e}",
input.local_manifest()
)
})?;
update_manifests(&packages_to_update, local_manifest_path, &all_packages)?;
update_manifests(&mut packages_to_update, local_manifest_path, &all_packages)?;
update_changelogs(input, &packages_to_update)?;
if !packages_to_update.updates.is_empty() {
let local_manifest_dir = input.local_manifest_dir()?;
Expand All @@ -121,7 +132,7 @@ pub fn update(input: &UpdateRequest) -> anyhow::Result<(PackagesUpdate, TempRepo
}

fn update_manifests(
packages_to_update: &PackagesUpdate,
packages_to_update: &mut PackagesUpdate,
local_manifest_path: &Path,
all_packages: &[Package],
) -> anyhow::Result<()> {
Expand All @@ -146,6 +157,10 @@ fn update_manifests(
debug!("new workspace version: {}", new_workspace_version);
if new_workspace_version > workspace_version {
local_manifest.set_workspace_version(&new_workspace_version);
for (pkg, _) in workspace_version_pkgs {
packages_to_update
.set_update_result_version(&pkg.name, new_workspace_version.clone());
}
local_manifest
.write()
.context("can't update workspace version")?;
Expand Down