diff options
| author | Brian Anderson <andersrb@gmail.com> | 2011-12-20 20:59:03 -0800 |
|---|---|---|
| committer | Brian Anderson <andersrb@gmail.com> | 2011-12-20 20:59:03 -0800 |
| commit | 085c813fe3f03c67aa8e8cb7fa005886d9447c50 (patch) | |
| tree | 8865168b706b9efe73c7420ee8e1bf40ed2c6282 | |
| parent | dedfef4c4c7a5e2d3f36d4301bfd9f7e1af21640 (diff) | |
| parent | bbc534bcccfc1904104a1fa275a6a873a7675cd1 (diff) | |
| download | rust-085c813fe3f03c67aa8e8cb7fa005886d9447c50.tar.gz rust-085c813fe3f03c67aa8e8cb7fa005886d9447c50.zip | |
Merge pull request #1365 from elly/cargo
cargo: allow 'ref' package key for git packages.
| -rw-r--r-- | src/cargo/cargo.rs | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/cargo/cargo.rs b/src/cargo/cargo.rs index 98c876e4986..99109f5d489 100644 --- a/src/cargo/cargo.rs +++ b/src/cargo/cargo.rs @@ -31,6 +31,7 @@ type package = { uuid: str, url: str, method: str, + ref: option::t<str>, tags: [str] }; @@ -242,6 +243,11 @@ fn load_one_source_package(&src: source, p: map::hashmap<str, json::json>) { } }; + let ref = alt p.find("ref") { + some(json::string(_n)) { some(_n) } + _ { none } + }; + let tags = []; alt p.find("tags") { some(json::list(js)) { @@ -260,6 +266,7 @@ fn load_one_source_package(&src: source, p: map::hashmap<str, json::json>) { uuid: uuid, url: url, method: method, + ref: ref, tags: tags }); log " Loaded package: " + src.name + "/" + name; @@ -398,8 +405,14 @@ fn install_source(c: cargo, path: str) { } } -fn install_git(c: cargo, wd: str, url: str) { +fn install_git(c: cargo, wd: str, url: str, ref: option::t<str>) { run::run_program("git", ["clone", url, wd]); + if option::is_some::<str>(ref) { + let r = option::get::<str>(ref); + fs::change_dir(wd); + run::run_program("git", ["checkout", r]); + } + install_source(c, wd); } @@ -424,7 +437,7 @@ fn install_file(c: cargo, wd: str, path: str) { fn install_package(c: cargo, wd: str, pkg: package) { info("Installing with " + pkg.method + " from " + pkg.url + "..."); if pkg.method == "git" { - install_git(c, wd, pkg.url); + install_git(c, wd, pkg.url, pkg.ref); } else if pkg.method == "http" { install_curl(c, wd, pkg.url); } else if pkg.method == "file" { |
