mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-28 11:20:36 +00:00
Fix sparse registry lockfile urls containing 'registry+sparse+'
This commit is contained in:
parent
0b84a35c2c
commit
931d8cbf99
@ -680,7 +680,13 @@ impl<'a> fmt::Display for SourceIdAsUrl<'a> {
|
|||||||
kind: SourceKind::Registry,
|
kind: SourceKind::Registry,
|
||||||
ref url,
|
ref url,
|
||||||
..
|
..
|
||||||
} => write!(f, "registry+{}", url),
|
} => {
|
||||||
|
if url.scheme().starts_with("sparse+") {
|
||||||
|
write!(f, "{}", url)
|
||||||
|
} else {
|
||||||
|
write!(f, "registry+{}", url)
|
||||||
|
}
|
||||||
|
}
|
||||||
SourceIdInner {
|
SourceIdInner {
|
||||||
kind: SourceKind::LocalRegistry,
|
kind: SourceKind::LocalRegistry,
|
||||||
ref url,
|
ref url,
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
//! Tests for alternative registries.
|
//! Tests for alternative registries.
|
||||||
|
|
||||||
use cargo::util::IntoUrl;
|
use cargo::util::IntoUrl;
|
||||||
|
use cargo_test_support::compare::assert_match_exact;
|
||||||
use cargo_test_support::publish::validate_alt_upload;
|
use cargo_test_support::publish::validate_alt_upload;
|
||||||
use cargo_test_support::registry::{self, Package, RegistryBuilder};
|
use cargo_test_support::registry::{self, Package, RegistryBuilder};
|
||||||
use cargo_test_support::{basic_manifest, git, paths, project};
|
use cargo_test_support::{basic_manifest, git, paths, project};
|
||||||
@ -1309,3 +1310,51 @@ fn both_index_and_registry() {
|
|||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cargo_test]
|
||||||
|
fn sparse_lockfile() {
|
||||||
|
let _registry = registry::RegistryBuilder::new()
|
||||||
|
.http_index()
|
||||||
|
.alternative()
|
||||||
|
.build();
|
||||||
|
Package::new("foo", "0.1.0").alternative(true).publish();
|
||||||
|
|
||||||
|
let p = project()
|
||||||
|
.file(
|
||||||
|
"Cargo.toml",
|
||||||
|
r#"
|
||||||
|
[project]
|
||||||
|
name = "a"
|
||||||
|
version = "0.5.0"
|
||||||
|
authors = []
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
foo = { registry = 'alternative', version = '0.1.0'}
|
||||||
|
"#,
|
||||||
|
)
|
||||||
|
.file("src/lib.rs", "")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
p.cargo("-Zsparse-registry generate-lockfile")
|
||||||
|
.masquerade_as_nightly_cargo(&["sparse-registry"])
|
||||||
|
.run();
|
||||||
|
assert_match_exact(
|
||||||
|
&p.read_lockfile(),
|
||||||
|
r#"# This file is automatically @generated by Cargo.
|
||||||
|
# It is not intended for manual editing.
|
||||||
|
version = 3
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "a"
|
||||||
|
version = "0.5.0"
|
||||||
|
dependencies = [
|
||||||
|
"foo",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "foo"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "sparse+http://[..]/"
|
||||||
|
checksum = "f6a200a9339fef960979d94d5c99cbbfd899b6f5a396a55d9775089119050203""#,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user