Some(token) => token,
None => {
let host = match options.flag_registry {
- Some(ref registry) => {
- config.get_registry_index(registry)?
+ Some(ref _registry) => {
+ return Err(CargoError::from("token must be provided when --registry is provided.").into());
}
None => {
let src = SourceId::crates_io(config)?;
}
pub fn alt_registry(config: &Config, key: &str) -> CargoResult<SourceId> {
- let index = config.get_registry_index(key)?;
- let url = index.to_url()?;
+ let url = config.get_registry_index(key)?;
Ok(SourceId {
inner: Arc::new(SourceIdInner {
kind: Kind::Registry,
let (index, token) = match registry {
Some(registry) => {
- let index = Some(config.get_registry_index(®istry)?);
+ let index = Some(config.get_registry_index(®istry)?.to_string());
let table = config.get_table(&format!("registry.{}", registry))?.map(|t| t.val);
let token = table.and_then(|table| {
match table.get("token".into()) {
use core::shell::Verbosity;
use core::{Shell, CliUnstable};
use ops;
+use url::Url;
+use util::ToUrl;
use util::Rustc;
use util::errors::{CargoResult, CargoResultExt, CargoError, internal};
use util::paths;
}
/// Gets the index for a registry.
- pub fn get_registry_index(&self, registry: &str) -> CargoResult<String> {
+ pub fn get_registry_index(&self, registry: &str) -> CargoResult<Url> {
Ok(match self.get_string(&format!("registries.{}.index", registry))? {
- Some(index) => index.val,
+ Some(index) => index.val.to_url()?,
None => return Err(CargoError::from(format!("No index found for registry: `{}`", registry)).into()),
})
}
token = "api-token"
[registries.test-reg]
- index = "dummy_index"
+ index = "http://dummy_index/"
[registries.test.reg]
- index = "dummy_index"
+ index = "http://dummy_index/"
"#;
fn setup_old_credentials() {