Skip to content

cargo: allow 'ref' package key for git packages. #1365

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 21, 2011
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions src/cargo/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type package = {
uuid: str,
url: str,
method: str,
ref: option::t<str>,
tags: [str]
};

Expand Down Expand Up @@ -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)) {
Expand All @@ -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;
Expand Down Expand Up @@ -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);
}

Expand All @@ -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" {
Expand Down