Skip to content

Commit 1770a97

Browse files
committed
---
yaml --- r: 6899 b: refs/heads/master c: 085c813 h: refs/heads/master i: 6897: 6ab06c9 6895: 5a713b2 v: v3
1 parent 9bc7a33 commit 1770a97

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: dedfef4c4c7a5e2d3f36d4301bfd9f7e1af21640
2+
refs/heads/master: 085c813fe3f03c67aa8e8cb7fa005886d9447c50

trunk/src/cargo/cargo.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ type package = {
3131
uuid: str,
3232
url: str,
3333
method: str,
34+
ref: option::t<str>,
3435
tags: [str]
3536
};
3637

@@ -242,6 +243,11 @@ fn load_one_source_package(&src: source, p: map::hashmap<str, json::json>) {
242243
}
243244
};
244245

246+
let ref = alt p.find("ref") {
247+
some(json::string(_n)) { some(_n) }
248+
_ { none }
249+
};
250+
245251
let tags = [];
246252
alt p.find("tags") {
247253
some(json::list(js)) {
@@ -260,6 +266,7 @@ fn load_one_source_package(&src: source, p: map::hashmap<str, json::json>) {
260266
uuid: uuid,
261267
url: url,
262268
method: method,
269+
ref: ref,
263270
tags: tags
264271
});
265272
log " Loaded package: " + src.name + "/" + name;
@@ -398,8 +405,14 @@ fn install_source(c: cargo, path: str) {
398405
}
399406
}
400407

401-
fn install_git(c: cargo, wd: str, url: str) {
408+
fn install_git(c: cargo, wd: str, url: str, ref: option::t<str>) {
402409
run::run_program("git", ["clone", url, wd]);
410+
if option::is_some::<str>(ref) {
411+
let r = option::get::<str>(ref);
412+
fs::change_dir(wd);
413+
run::run_program("git", ["checkout", r]);
414+
}
415+
403416
install_source(c, wd);
404417
}
405418

@@ -424,7 +437,7 @@ fn install_file(c: cargo, wd: str, path: str) {
424437
fn install_package(c: cargo, wd: str, pkg: package) {
425438
info("Installing with " + pkg.method + " from " + pkg.url + "...");
426439
if pkg.method == "git" {
427-
install_git(c, wd, pkg.url);
440+
install_git(c, wd, pkg.url, pkg.ref);
428441
} else if pkg.method == "http" {
429442
install_curl(c, wd, pkg.url);
430443
} else if pkg.method == "file" {

0 commit comments

Comments
 (0)