Skip to content

Commit

Permalink
Allow upgrade for crates with path
Browse files Browse the repository at this point in the history
* Do not remove keys
* Allow all crates to be updated (don't use is_version_dep)
  • Loading branch information
maxv-rust committed Oct 24, 2020
1 parent 123a2de commit 8b4bfa3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
1 change: 0 additions & 1 deletion src/bin/upgrade/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,6 @@ impl Manifests {
self.0
.iter()
.flat_map(|&(_, ref package)| package.dependencies.clone())
.filter(is_version_dep)
.filter_map(|dependency| {
let is_prerelease = dependency.req.to_string().contains('-');
if selected_dependencies.is_empty() {
Expand Down
15 changes: 8 additions & 7 deletions src/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,17 @@ fn merge_dependencies(old_dep: &mut toml_edit::Item, new: &Dependency) {

let new_toml = new.to_toml().1;

if str_or_1_len_table(old_dep) {
// The old dependency is just a version/git/path. We are safe to overwrite.
if old_dep.is_str() {
// The old dependency is just a version. We are safe to overwrite.
*old_dep = new_toml;
} else if old_dep.is_table_like() {
for key in &["version", "path", "git"] {
// remove this key/value pairs
old_dep[key] = toml_edit::Item::None;
}
if let Some(name) = new_toml.as_str() {
old_dep["version"] = toml_edit::value(name);
match &mut old_dep["version"] {
// There may be a reason the crate doesn't have a version
toml_edit::Item::None => {},
// Update the version old version with the new one
version => *version = toml_edit::value(name),
}
} else {
merge_inline_table(old_dep, &new_toml);
}
Expand Down

0 comments on commit 8b4bfa3

Please sign in to comment.