cargo: support github:<user>/<repo>
This commit is contained in:
parent
0acf170c9f
commit
f05eaa4a65
@ -194,27 +194,15 @@ fn install_source(c: cargo, path: str) {
|
||||
}
|
||||
}
|
||||
|
||||
fn install_git(c: cargo, _path: str) {
|
||||
let wd = tempfile::mkdtemp(c.workdir + fs::path_sep(), "");
|
||||
alt wd {
|
||||
some(p) {
|
||||
run::run_program("git", ["clone", _path, p]);
|
||||
install_source(c, p);
|
||||
}
|
||||
_ { fail "needed temp dir"; }
|
||||
}
|
||||
fn install_git(c: cargo, wd: str, _path: str) {
|
||||
run::run_program("git", ["clone", _path, wd]);
|
||||
install_source(c, wd);
|
||||
}
|
||||
|
||||
fn install_file(c: cargo, _path: str) {
|
||||
let wd = tempfile::mkdtemp(c.workdir + fs::path_sep(), "");
|
||||
alt wd {
|
||||
some(p) {
|
||||
run::run_program("tar", ["-x", "--strip-components=1",
|
||||
"-C", p, "-f", _path]);
|
||||
install_source(c, p);
|
||||
}
|
||||
_ { fail "needed temp dir"; }
|
||||
}
|
||||
fn install_file(c: cargo, wd: str, _path: str) {
|
||||
run::run_program("tar", ["-x", "--strip-components=1",
|
||||
"-C", wd, "-f", _path]);
|
||||
install_source(c, wd);
|
||||
}
|
||||
|
||||
fn cmd_install(c: cargo, argv: [str]) {
|
||||
@ -224,12 +212,19 @@ fn cmd_install(c: cargo, argv: [str]) {
|
||||
ret;
|
||||
}
|
||||
|
||||
let wd = alt tempfile::mkdtemp(c.workdir + fs::path_sep(), "") {
|
||||
some(_wd) { _wd }
|
||||
none. { fail "needed temp dir"; }
|
||||
};
|
||||
|
||||
if str::starts_with(argv[2], "git:") {
|
||||
install_git(c, argv[2]);
|
||||
}
|
||||
if str::starts_with(argv[2], "file:") {
|
||||
install_git(c, wd, argv[2]);
|
||||
} else if str::starts_with(argv[2], "github:") {
|
||||
let path = rest(argv[2], 7u);
|
||||
install_git(c, wd, "git://github.com/" + path);
|
||||
} else if str::starts_with(argv[2], "file:") {
|
||||
let path = rest(argv[2], 5u);
|
||||
install_file(c, path);
|
||||
install_file(c, wd, path);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user