mirror of
https://github.com/rust-lang/cargo.git
synced 2025-10-01 11:30:39 +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> {
|
namespace: &SourceId) -> CargoResult<Dependency> {
|
||||||
|
|
||||||
|
let version = match version {
|
||||||
|
Some(v) => try!(VersionReq::parse(v)),
|
||||||
|
None => VersionReq::any()
|
||||||
|
};
|
||||||
|
|
||||||
Ok(Dependency {
|
Ok(Dependency {
|
||||||
name: name.to_str(),
|
name: name.to_str(),
|
||||||
namespace: namespace.clone(),
|
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 url = url::from_str("http://example.com").unwrap();
|
||||||
let source_id = SourceId::new(RegistryKind, url);
|
let source_id = SourceId::new(RegistryKind, url);
|
||||||
let d: Vec<Dependency> = vec!($($deps),+).iter().map(|s| {
|
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();
|
}).collect();
|
||||||
Summary::new(&PackageId::new($name, "1.0.0",
|
Summary::new(&PackageId::new($name, "1.0.0",
|
||||||
"http://www.example.com/"),
|
"http://www.example.com/"),
|
||||||
@ -107,7 +107,7 @@ mod test {
|
|||||||
fn dep(name: &str) -> Dependency {
|
fn dep(name: &str) -> Dependency {
|
||||||
let url = url::from_str("http://example.com").unwrap();
|
let url = url::from_str("http://example.com").unwrap();
|
||||||
let source_id = SourceId::new(RegistryKind, url);
|
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> {
|
fn registry(pkgs: Vec<Summary>) -> Vec<Summary> {
|
||||||
|
@ -34,6 +34,10 @@ struct PredBuilder {
|
|||||||
|
|
||||||
|
|
||||||
impl VersionReq {
|
impl VersionReq {
|
||||||
|
pub fn any() -> VersionReq {
|
||||||
|
VersionReq { predicates: vec!() }
|
||||||
|
}
|
||||||
|
|
||||||
pub fn parse(input: &str) -> CargoResult<VersionReq> {
|
pub fn parse(input: &str) -> CargoResult<VersionReq> {
|
||||||
let mut lexer = Lexer::new(input);
|
let mut lexer = Lexer::new(input);
|
||||||
let mut builder = PredBuilder::new();
|
let mut builder = PredBuilder::new();
|
||||||
|
@ -68,7 +68,7 @@ pub enum TomlDependency {
|
|||||||
|
|
||||||
#[deriving(Encodable,Decodable,PartialEq,Clone,Show)]
|
#[deriving(Encodable,Decodable,PartialEq,Clone,Show)]
|
||||||
pub struct DetailedTomlDependency {
|
pub struct DetailedTomlDependency {
|
||||||
version: String,
|
version: Option<String>,
|
||||||
path: Option<String>,
|
path: Option<String>,
|
||||||
git: Option<String>,
|
git: Option<String>,
|
||||||
}
|
}
|
||||||
@ -119,7 +119,7 @@ impl TomlManifest {
|
|||||||
for (n, v) in dependencies.iter() {
|
for (n, v) in dependencies.iter() {
|
||||||
let (version, source_id) = match *v {
|
let (version, source_id) = match *v {
|
||||||
SimpleDep(ref string) => {
|
SimpleDep(ref string) => {
|
||||||
(string.clone(), SourceId::for_central())
|
(Some(string.clone()), SourceId::for_central())
|
||||||
},
|
},
|
||||||
DetailedDep(ref details) => {
|
DetailedDep(ref details) => {
|
||||||
let new_source_id = details.git.as_ref().map(|git| {
|
let new_source_id = details.git.as_ref().map(|git| {
|
||||||
@ -142,7 +142,7 @@ impl TomlManifest {
|
|||||||
};
|
};
|
||||||
|
|
||||||
deps.push(try!(Dependency::parse(n.as_slice(),
|
deps.push(try!(Dependency::parse(n.as_slice(),
|
||||||
version.as_slice(),
|
version.as_ref().map(|v| v.as_slice()),
|
||||||
&source_id)))
|
&source_id)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,6 @@ test!(cargo_compile_simple_git_dep {
|
|||||||
|
|
||||||
[dependencies.dep1]
|
[dependencies.dep1]
|
||||||
|
|
||||||
version = "0.5.0"
|
|
||||||
git = "file://{}"
|
git = "file://{}"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user