History

[smart-release #155] don't set versions if the new ones match

Sebastian Thiel committed 5 years ago

Commit dd0f4281 parent 07dc6d81 file · +14 −9Browse files

Unified · Split

cargo-smart-release/src/command/release/manifest.rs+14−9
@@ -5,6 +5,7 @@ use super::{ · 4 unmodified lines
55 };
66 use cargo_metadata::{Metadata, Package};
77 use git_repository::hash::ObjectId;
8+use semver::{Version, VersionReq};
89 use std::{collections::BTreeMap, str::FromStr};
910
1011 pub(in crate::command::release_impl) fn edit_version_and_fixup_dependent_crates(
@@ -102,6 +103,7 @@ fn set_version_and_update_package_dependency( · 91 unmodified lines
102103 }
103104 for dep_type in &["dependencies", "dev-dependencies", "build-dependencies"] {
104105 for (name_to_find, new_version) in publishees.iter().map(|(p, nv)| (&p.name, nv)) {
106+ let new_version = Version::parse(new_version)?;
105107 for name_to_find in package_to_update
106108 .dependencies
107109 .iter()
@@ -115,15 +117,18 @@ fn set_version_and_update_package_dependency( · 7 unmodified lines
115117 .and_then(|deps| deps.get_mut(name_to_find).and_then(|name| name.as_inline_table_mut()))
116118 .and_then(|name_table| name_table.get_mut("version"))
117119 {
118− log::info!(
119− "Pending '{}' manifest {} update: '{} = \"{}\"' (from {})",
120− package_to_update.name,
121− dep_type,
122− name_to_find,
123− new_version,
124− current_version
125− );
126− *current_version = toml_edit::Value::from(new_version.as_str());
120+ let version_req = VersionReq::parse(&current_version.as_str().expect("versions are strings"))?;
121+ if !version_req.matches(&new_version) {
122+ log::info!(
123+ "Pending '{}' manifest {} update: '{} = \"{}\"' (from {})",
124+ package_to_update.name,
125+ dep_type,
126+ name_to_find,
127+ new_version,
128+ current_version
129+ );
130+ *current_version = toml_edit::Value::from(new_version.to_string().as_str());
131+ }
127132 }
128133 }
129134 }