mirror of
https://github.com/rust-lang/cargo
synced 2024-10-14 19:52:45 +00:00
Allow absent git version
This commit is contained in:
parent
de6944798c
commit
860ca08ad2
|
@ -19,12 +19,18 @@ impl Dependency {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn parse(name: &str, version: &str,
|
||||
pub fn parse(name: &str, version: Option<&str>,
|
||||
namespace: &SourceId) -> CargoResult<Dependency> {
|
||||
|
||||
let version = match version {
|
||||
Some(v) => try!(VersionReq::parse(v)),
|
||||
None => VersionReq::any()
|
||||
};
|
||||
|
||||
Ok(Dependency {
|
||||
name: name.to_str(),
|
||||
namespace: namespace.clone(),
|
||||
req: try!(VersionReq::parse(version)),
|
||||
req: version
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -85,7 +85,7 @@ mod test {
|
|||
let url = url::from_str("http://example.com").unwrap();
|
||||
let source_id = SourceId::new(RegistryKind, url);
|
||||
let d: Vec<Dependency> = vec!($($deps),+).iter().map(|s| {
|
||||
Dependency::parse(*s, "1.0.0", &source_id).unwrap()
|
||||
Dependency::parse(*s, Some("1.0.0"), &source_id).unwrap()
|
||||
}).collect();
|
||||
Summary::new(&PackageId::new($name, "1.0.0",
|
||||
"http://www.example.com/"),
|
||||
|
@ -107,7 +107,7 @@ mod test {
|
|||
fn dep(name: &str) -> Dependency {
|
||||
let url = url::from_str("http://example.com").unwrap();
|
||||
let source_id = SourceId::new(RegistryKind, url);
|
||||
Dependency::parse(name, "1.0.0", &source_id).unwrap()
|
||||
Dependency::parse(name, Some("1.0.0"), &source_id).unwrap()
|
||||
}
|
||||
|
||||
fn registry(pkgs: Vec<Summary>) -> Vec<Summary> {
|
||||
|
|
|
@ -34,6 +34,10 @@ struct PredBuilder {
|
|||
|
||||
|
||||
impl VersionReq {
|
||||
pub fn any() -> VersionReq {
|
||||
VersionReq { predicates: vec!() }
|
||||
}
|
||||
|
||||
pub fn parse(input: &str) -> CargoResult<VersionReq> {
|
||||
let mut lexer = Lexer::new(input);
|
||||
let mut builder = PredBuilder::new();
|
||||
|
|
|
@ -68,7 +68,7 @@ pub enum TomlDependency {
|
|||
|
||||
#[deriving(Encodable,Decodable,PartialEq,Clone,Show)]
|
||||
pub struct DetailedTomlDependency {
|
||||
version: String,
|
||||
version: Option<String>,
|
||||
path: Option<String>,
|
||||
git: Option<String>,
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ impl TomlManifest {
|
|||
for (n, v) in dependencies.iter() {
|
||||
let (version, source_id) = match *v {
|
||||
SimpleDep(ref string) => {
|
||||
(string.clone(), SourceId::for_central())
|
||||
(Some(string.clone()), SourceId::for_central())
|
||||
},
|
||||
DetailedDep(ref details) => {
|
||||
let new_source_id = details.git.as_ref().map(|git| {
|
||||
|
@ -142,7 +142,7 @@ impl TomlManifest {
|
|||
};
|
||||
|
||||
deps.push(try!(Dependency::parse(n.as_slice(),
|
||||
version.as_slice(),
|
||||
version.as_ref().map(|v| v.as_slice()),
|
||||
&source_id)))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,7 +73,6 @@ test!(cargo_compile_simple_git_dep {
|
|||
|
||||
[dependencies.dep1]
|
||||
|
||||
version = "0.5.0"
|
||||
git = "file://{}"
|
||||
|
||||
[[bin]]
|
||||
|
|
Loading…
Reference in a new issue