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.
This commit is contained in:
Weihang Lo 2024-01-18 00:29:23 -05:00
parent a37d122949
commit 637b5d1eae
No known key found for this signature in database
GPG Key ID: D7DBF189825E82E7
2 changed files with 6 additions and 3 deletions

View File

@ -195,7 +195,7 @@ fn opt_patterns_and_names(
let mut opt_patterns = Vec::new();
let mut opt_names = BTreeSet::new();
for x in opt.iter() {
if is_glob_pattern(x) {
if PackageIdSpec::parse(x).is_err() && is_glob_pattern(x) {
opt_patterns.push((build_glob(x)?, false));
} else {
opt_names.insert(String::as_str(x));

View File

@ -1553,7 +1553,10 @@ fn pkgid_querystring_works() {
p.cargo("build -p")
.arg(gitdep_pkgid)
.with_status(101)
.with_stderr("[ERROR] package pattern(s) `git+file:///[..]/gitdep?branch=master#1.0.0` not found in workspace `[CWD]`")
.with_stderr(
"\
[COMPILING] gitdep v1.0.0 (file:///[..]/gitdep?branch=master#[..])
[FINISHED] dev [..]",
)
.run();
}