File tree 2 files changed +56
-1
lines changed
2 files changed +56
-1
lines changed Original file line number Diff line number Diff line change @@ -680,7 +680,13 @@ impl<'a> fmt::Display for SourceIdAsUrl<'a> {
680
680
kind : SourceKind :: Registry ,
681
681
ref url,
682
682
..
683
- } => write ! ( f, "registry+{}" , url) ,
683
+ } => {
684
+ if url. scheme ( ) . starts_with ( "sparse+" ) {
685
+ write ! ( f, "{}" , url)
686
+ } else {
687
+ write ! ( f, "registry+{}" , url)
688
+ }
689
+ }
684
690
SourceIdInner {
685
691
kind : SourceKind :: LocalRegistry ,
686
692
ref url,
Original file line number Diff line number Diff line change 1
1
//! Tests for alternative registries.
2
2
3
3
use cargo:: util:: IntoUrl ;
4
+ use cargo_test_support:: compare:: assert_match_exact;
4
5
use cargo_test_support:: publish:: validate_alt_upload;
5
6
use cargo_test_support:: registry:: { self , Package , RegistryBuilder } ;
6
7
use cargo_test_support:: { basic_manifest, git, paths, project} ;
@@ -1309,3 +1310,51 @@ fn both_index_and_registry() {
1309
1310
. run ( ) ;
1310
1311
}
1311
1312
}
1313
+
1314
+ #[ cargo_test]
1315
+ fn sparse_lockfile ( ) {
1316
+ let _registry = registry:: RegistryBuilder :: new ( )
1317
+ . http_index ( )
1318
+ . alternative ( )
1319
+ . build ( ) ;
1320
+ Package :: new ( "foo" , "0.1.0" ) . alternative ( true ) . publish ( ) ;
1321
+
1322
+ let p = project ( )
1323
+ . file (
1324
+ "Cargo.toml" ,
1325
+ r#"
1326
+ [project]
1327
+ name = "a"
1328
+ version = "0.5.0"
1329
+ authors = []
1330
+
1331
+ [dependencies]
1332
+ foo = { registry = 'alternative', version = '0.1.0'}
1333
+ "# ,
1334
+ )
1335
+ . file ( "src/lib.rs" , "" )
1336
+ . build ( ) ;
1337
+
1338
+ p. cargo ( "-Zsparse-registry generate-lockfile" )
1339
+ . masquerade_as_nightly_cargo ( & [ "sparse-registry" ] )
1340
+ . run ( ) ;
1341
+ assert_match_exact (
1342
+ & p. read_lockfile ( ) ,
1343
+ r#"# This file is automatically @generated by Cargo.
1344
+ # It is not intended for manual editing.
1345
+ version = 3
1346
+
1347
+ [[package]]
1348
+ name = "a"
1349
+ version = "0.5.0"
1350
+ dependencies = [
1351
+ "foo",
1352
+ ]
1353
+
1354
+ [[package]]
1355
+ name = "foo"
1356
+ version = "0.1.0"
1357
+ source = "sparse+http://[..]/"
1358
+ checksum = "f6a200a9339fef960979d94d5c99cbbfd899b6f5a396a55d9775089119050203""# ,
1359
+ ) ;
1360
+ }
You can’t perform that action at this time.
0 commit comments