mirror of
https://github.com/rust-lang/cargo
synced 2024-10-14 03:32:39 +00:00
Updating based on review comments.
This commit is contained in:
parent
0f82507ec1
commit
0bda323c08
|
@ -55,8 +55,8 @@ pub fn execute(options: Options, config: &mut Config) -> CliResult {
|
|||
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)?;
|
||||
|
|
|
@ -183,8 +183,7 @@ impl SourceId {
|
|||
}
|
||||
|
||||
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,
|
||||
|
|
|
@ -196,7 +196,7 @@ pub fn registry_configuration(config: &Config,
|
|||
|
||||
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()) {
|
||||
|
|
|
@ -20,6 +20,8 @@ use toml;
|
|||
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;
|
||||
|
@ -546,9 +548,9 @@ impl Config {
|
|||
}
|
||||
|
||||
/// 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()),
|
||||
})
|
||||
}
|
||||
|
|
|
@ -22,10 +22,10 @@ const CONFIG_FILE: &str = r#"
|
|||
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() {
|
||||
|
|
Loading…
Reference in a new issue