Skip to content

Commit 8f5afcf

Browse files
committed
Update cargo to latest revision
Fixes: #65
1 parent a8a3ece commit 8f5afcf

File tree

3 files changed

+56
-38
lines changed

3 files changed

+56
-38
lines changed

Cargo.lock

Lines changed: 36 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ postgres = { version = "^0.11", features = [ "time", "rustc-serialize" ] }
1515
clap = "2.5.2"
1616
time = "0.1"
1717
hyper = "0.9.7"
18-
semver = "0.2.2"
18+
semver = "0.4"
1919
slug = "^0.1.1"
2020
env_logger = "0.3"
2121
git2 = "0.4"
@@ -35,7 +35,7 @@ error-chain = "0.5"
3535

3636
[dependencies.cargo]
3737
git = "https://github.com/rust-lang/cargo.git"
38-
rev = "ffa147d393037fd5632cd8c9d048b5521d70ab4c"
38+
rev = "c917e94b419ce62760c0a6fdcf90ff0d7d1d5cdb"
3939

4040
[dev-dependencies]
4141
tempdir = "0.3"

src/utils/build_doc.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
use std::path::{Path, PathBuf};
77
use std::env;
88

9-
use cargo::core::{SourceId, Dependency, Registry, Source, Package};
9+
use cargo::core::{SourceId, Dependency, Registry, Source, Package, Workspace};
1010
use cargo::util::{CargoResult, Config, human, Filesystem};
11-
use cargo::sources::RegistrySource;
12-
use cargo::{ops, ChainError};
11+
use cargo::sources::SourceConfigMap;
12+
use cargo::ops;
1313

1414

1515
/// Builds documentation of a crate and version.
@@ -22,9 +22,10 @@ use cargo::{ops, ChainError};
2222
// instead of doing it manually like in the previous version of cratesfyi
2323
pub fn build_doc(name: &str, vers: Option<&str>, target: Option<&str>) -> CargoResult<Package> {
2424
let config = try!(Config::default());
25-
let source_id = try!(SourceId::for_central(&config));
25+
let source_id = try!(SourceId::crates_io(&config));
2626

27-
let mut source = RegistrySource::new(&source_id, &config);
27+
let source_map = try!(SourceConfigMap::new(&config));
28+
let mut source = try!(source_map.load(&source_id));
2829

2930
// update crates.io-index registry
3031
try!(source.update());
@@ -38,10 +39,8 @@ pub fn build_doc(name: &str, vers: Option<&str>, target: Option<&str>) -> CargoR
3839
.unwrap_or(Err(human("PKG download error"))));
3940

4041
let current_dir = try!(env::current_dir());
41-
let target_dir = PathBuf::from(current_dir).join(
42-
format!("{}-{}", pkg.manifest().name(), pkg.manifest().version()));
43-
44-
config.set_target_dir(Filesystem::new(target_dir.clone()));
42+
let target_dir = PathBuf::from(current_dir)
43+
.join(format!("{}-{}", pkg.manifest().name(), pkg.manifest().version()));
4544

4645
let opts = ops::CompileOptions {
4746
config: &config,
@@ -58,12 +57,11 @@ pub fn build_doc(name: &str, vers: Option<&str>, target: Option<&str>) -> CargoR
5857
target_rustdoc_args: None,
5958
};
6059

61-
try!(ops::compile_pkg(&pkg, Some(Box::new(source)), &opts).chain_error(|| {
62-
human(format!("failed to compile `{}`, intermediate artifacts can be \
63-
found at `{}`", pkg, target_dir.display()))
64-
}));
60+
let ws = try!(Workspace::one(pkg, &config, Some(Filesystem::new(target_dir))));
6561

66-
Ok(pkg)
62+
try!(ops::compile_ws(&ws, Some(source), &opts));
63+
64+
Ok(try!(ws.current()).clone())
6765
}
6866

6967

@@ -72,9 +70,10 @@ pub fn build_doc(name: &str, vers: Option<&str>, target: Option<&str>) -> CargoR
7270
pub fn get_package(name: &str, vers: Option<&str>) -> CargoResult<Package> {
7371
debug!("Getting package with cargo");
7472
let config = try!(Config::default());
75-
let source_id = try!(SourceId::for_central(&config));
73+
let source_id = try!(SourceId::crates_io(&config));
7674

77-
let mut source = RegistrySource::new(&source_id, &config);
75+
let source_map = try!(SourceConfigMap::new(&config));
76+
let mut source = try!(source_map.load(&source_id));
7877

7978
let dep = try!(Dependency::parse(name, vers, &source_id));
8079
let deps = try!(source.query(&dep));
@@ -91,9 +90,10 @@ pub fn get_package(name: &str, vers: Option<&str>) -> CargoResult<Package> {
9190
/// Updates central crates-io.index repository
9291
pub fn update_sources() -> CargoResult<()> {
9392
let config = try!(Config::default());
94-
let source_id = try!(SourceId::for_central(&config));
93+
let source_id = try!(SourceId::crates_io(&config));
9594

96-
let mut source = RegistrySource::new(&source_id, &config);
95+
let source_map = try!(SourceConfigMap::new(&config));
96+
let mut source = try!(source_map.load(&source_id));
9797

9898
source.update()
9999
}

0 commit comments

Comments
 (0)