Skip to content

Commit

Permalink
Sort out bug with updating registry on a clean build.
Browse files Browse the repository at this point in the history
  • Loading branch information
cswindle committed Nov 6, 2017
1 parent 93c0d7c commit 4a302ac
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
20 changes: 10 additions & 10 deletions src/cargo/core/source/source_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ struct SourceIdInner {
kind: Kind,
// e.g. the exact git revision of the specified branch for a Git Source
precise: Option<String>,
/// Name of the registry source for alternative registries
name: Option<String>,
}

/// The possible kinds of code source. Along with a URL, this fully defines the
Expand All @@ -44,8 +46,6 @@ enum Kind {
Path,
/// represents a remote registry
Registry,
/// represents a remote alternative registry
AltRegistry,
/// represents a local filesystem-based registry
LocalRegistry,
/// represents a directory-based registry
Expand Down Expand Up @@ -74,6 +74,7 @@ impl SourceId {
canonical_url: git::canonicalize_url(&url)?,
url: url,
precise: None,
name: None,
}),
};
Ok(source_id)
Expand Down Expand Up @@ -188,10 +189,11 @@ impl SourceId {
let url = config.get_registry_index(key)?;
Ok(SourceId {
inner: Arc::new(SourceIdInner {
kind: Kind::AltRegistry,
kind: Kind::Registry,
canonical_url: git::canonicalize_url(&url)?,
url: url,
precise: None,
name: Some(key.to_string()),
}),
})
}
Expand All @@ -213,14 +215,14 @@ impl SourceId {
/// Is this source from a registry (either local or not)
pub fn is_registry(&self) -> bool {
match self.inner.kind {
Kind::Registry | Kind::AltRegistry | Kind::LocalRegistry => true,
_ => false,
Kind::Registry | Kind::LocalRegistry => true,
_ => false,
}
}

/// Is this source from an alternative registry
pub fn is_alt_registry(&self) -> bool {
self.inner.kind == Kind::AltRegistry
self.is_registry() && self.inner.name.is_some()
}

/// Is this source from a git repository
Expand All @@ -243,7 +245,7 @@ impl SourceId {
};
Ok(Box::new(PathSource::new(&path, self, config)))
}
Kind::Registry | Kind::AltRegistry => Ok(Box::new(RegistrySource::remote(self, config))),
Kind::Registry => Ok(Box::new(RegistrySource::remote(self, config))),
Kind::LocalRegistry => {
let path = match self.inner.url.to_file_path() {
Ok(p) => p,
Expand Down Expand Up @@ -368,7 +370,6 @@ impl fmt::Display for SourceId {
Ok(())
}
SourceIdInner { kind: Kind::Registry, ref url, .. } |
SourceIdInner { kind: Kind::AltRegistry, ref url, .. } |
SourceIdInner { kind: Kind::LocalRegistry, ref url, .. } => {
write!(f, "registry `{}`", url)
}
Expand Down Expand Up @@ -466,8 +467,7 @@ impl<'a> fmt::Display for SourceIdToUrl<'a> {
}
Ok(())
}
SourceIdInner { kind: Kind::Registry, ref url, .. } |
SourceIdInner { kind: Kind::AltRegistry, ref url, .. } => {
SourceIdInner { kind: Kind::Registry, ref url, .. } => {
write!(f, "registry+{}", url)
}
SourceIdInner { kind: Kind::LocalRegistry, ref url, .. } => {
Expand Down
4 changes: 1 addition & 3 deletions tests/alt-registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,11 @@ fn depend_on_alt_registry() {
// Don't download a second time
assert_that(p.cargo("build").masquerade_as_nightly_cargo(),
execs().with_status(0).with_stderr(&format!("\
[UPDATING] registry `{reg}`
[COMPILING] bar v0.0.1 (registry `file://[..]`)
[COMPILING] foo v0.0.1 ({dir})
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] secs
",
dir = p.url(),
reg = registry::alt_registry())));
dir = p.url())));
}

#[test]
Expand Down

0 comments on commit 4a302ac

Please sign in to comment.