Commit 40086e8
authored
fix(info): default to local without explicit reg (#16358)
### What does this PR try to resolve?
close #16145
[`93c2c40`
(#16358)](93c2c40)
shouldn't be an error; it should inspect the local package correctly.
The reason it is buggy is as follows: The `default_registry` function
attempts to retrieve the default registry from the user's configuration;
in this case, it is crates-io.
```rust
in src/cargo/ops/registry/mod.rs:210-248(get_source_id_with_package_id):
(Some(reg_or_index), Some(package_id)) => {
let sid = get_initial_source_id_from_registry_or_index(gctx,
reg_or_index)?; // crates-io
let package_source_id = package_id.source_id(); // local path source
// Check if they match or if one replaces the other
if sid == package_source_id // false: crates-io != path
|| is_replacement_for_package_source(gctx, sid,
package_source_id)? // false: no replacement for local path
{
(true, package_source_id)
} else {
(false, sid) // <-- Returns this: "don't use local package,
search in registry"
}
}
```
In this PR, I modified the cargo-info to prefer the local package if the
registry is not explicitly specified.
### How to test and review this PR?
Check the unit test.
1. One case for reproducing the described issue. It shouldn't be an
error. We should inspect the local package properly.
2. Another case specifies the registry configured in the config file to
ensure we can search the registry correctly.
r? @ghostFile tree
32 files changed
+304
-2
lines changed- src
- bin/cargo/commands
- cargo/ops/registry/info
- tests/testsuite/cargo_info
- with_default_registry_configured_and_specified
- in
- .cargo
- crates/crate1
- src
- src
- out
- .cargo
- crates/crate1
- src
- src
- with_default_registry_configured
- in
- .cargo
- crates/crate1
- src
- src
- out
- .cargo
- crates/crate1
- src
- src
32 files changed
+304
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
| 33 | + | |
32 | 34 | | |
33 | | - | |
| 35 | + | |
34 | 36 | | |
35 | 37 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| |||
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
42 | 52 | | |
43 | | - | |
| 53 | + | |
44 | 54 | | |
45 | 55 | | |
46 | 56 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
| 21 | + | |
20 | 22 | | |
21 | 23 | | |
22 | 24 | | |
| |||
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 9 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
Lines changed: 24 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
0 commit comments