ktra
ktra copied to clipboard
Dependency listed incorrectly if it has aliased
Hi @moriturus, thanks for open-sourcing this useful project. It works very smoothly(especially with Docker containers :D), but I believe there is a subtle bug:
When a package to be published has a dependency with package field, ktra places it into index wrongly.
Steps to reproduce:
- Create a dummy package(say
foo)
[package]
name = "foo"
version = "0.1.0"
edition = "2018"
[dependencies]
hello-world = { version = "*", package = "hello" }
- Publish it
- Referring Cargo reference, the added index should have dependency with fields
"name": "hello-world", "package": "hello", but two fields are interchanged. This causes confusing dependency resolution failure on cargo fetch(no matching package), althoughcargo searchon ktra registry returns the exact package.
To resolve, Into<Dependency> impl of MetadataDependency should swap two fields.
https://github.com/moriturus/ktra/blob/8a14cd2a5b9edf6c7de8a56f0c72462716e2ddde/src/models.rs#L19-L34
(possibly fixing) change:
Dependency {
name: self
.explicit_name_in_toml
.clone()
.unwrap_or_else(|| self.name.clone()),
req: self.version_req,
features: self.features,
optional: self.optional,
default_features: self.default_features,
target: self.target,
kind: self.kind,
registry: self.registry,
package: if self.explicit_name_in_toml.is_some() {
Some(self.name)
} else {
None
},
}
Thanks in advance!