Skip to content

Commit 637b5d1

Browse files
committed
fix(--package): accept ? if it's a valid pkgid spec
Previously if a value from `--package` flag contains `?`, Cargo considered it as a glob pattern. However, staring from 12933 the Package Id Spec has been extended to accept `?` for git sources. This PR adjust accordingly to accept `?` from `--package` flag when it is a valid Package Id Spec.
1 parent a37d122 commit 637b5d1

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/cargo/ops/cargo_compile/packages.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ fn opt_patterns_and_names(
195195
let mut opt_patterns = Vec::new();
196196
let mut opt_names = BTreeSet::new();
197197
for x in opt.iter() {
198-
if is_glob_pattern(x) {
198+
if PackageIdSpec::parse(x).is_err() && is_glob_pattern(x) {
199199
opt_patterns.push((build_glob(x)?, false));
200200
} else {
201201
opt_names.insert(String::as_str(x));

tests/testsuite/check.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1553,7 +1553,10 @@ fn pkgid_querystring_works() {
15531553

15541554
p.cargo("build -p")
15551555
.arg(gitdep_pkgid)
1556-
.with_status(101)
1557-
.with_stderr("[ERROR] package pattern(s) `git+file:///[..]/gitdep?branch=master#1.0.0` not found in workspace `[CWD]`")
1556+
.with_stderr(
1557+
"\
1558+
[COMPILING] gitdep v1.0.0 (file:///[..]/gitdep?branch=master#[..])
1559+
[FINISHED] dev [..]",
1560+
)
15581561
.run();
15591562
}

0 commit comments

Comments
 (0)