Skip to content

Commit f05eaa4

Browse files
Elly Jonesgraydon
Elly Jones
authored andcommitted
cargo: support github:<user>/<repo>
1 parent 0acf170 commit f05eaa4

File tree

1 file changed

+18
-23
lines changed

1 file changed

+18
-23
lines changed

src/cargo/cargo.rs

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -194,27 +194,15 @@ fn install_source(c: cargo, path: str) {
194194
}
195195
}
196196

197-
fn install_git(c: cargo, _path: str) {
198-
let wd = tempfile::mkdtemp(c.workdir + fs::path_sep(), "");
199-
alt wd {
200-
some(p) {
201-
run::run_program("git", ["clone", _path, p]);
202-
install_source(c, p);
203-
}
204-
_ { fail "needed temp dir"; }
205-
}
197+
fn install_git(c: cargo, wd: str, _path: str) {
198+
run::run_program("git", ["clone", _path, wd]);
199+
install_source(c, wd);
206200
}
207201

208-
fn install_file(c: cargo, _path: str) {
209-
let wd = tempfile::mkdtemp(c.workdir + fs::path_sep(), "");
210-
alt wd {
211-
some(p) {
212-
run::run_program("tar", ["-x", "--strip-components=1",
213-
"-C", p, "-f", _path]);
214-
install_source(c, p);
215-
}
216-
_ { fail "needed temp dir"; }
217-
}
202+
fn install_file(c: cargo, wd: str, _path: str) {
203+
run::run_program("tar", ["-x", "--strip-components=1",
204+
"-C", wd, "-f", _path]);
205+
install_source(c, wd);
218206
}
219207

220208
fn cmd_install(c: cargo, argv: [str]) {
@@ -224,12 +212,19 @@ fn cmd_install(c: cargo, argv: [str]) {
224212
ret;
225213
}
226214

215+
let wd = alt tempfile::mkdtemp(c.workdir + fs::path_sep(), "") {
216+
some(_wd) { _wd }
217+
none. { fail "needed temp dir"; }
218+
};
219+
227220
if str::starts_with(argv[2], "git:") {
228-
install_git(c, argv[2]);
229-
}
230-
if str::starts_with(argv[2], "file:") {
221+
install_git(c, wd, argv[2]);
222+
} else if str::starts_with(argv[2], "github:") {
223+
let path = rest(argv[2], 7u);
224+
install_git(c, wd, "git://github.com/" + path);
225+
} else if str::starts_with(argv[2], "file:") {
231226
let path = rest(argv[2], 5u);
232-
install_file(c, path);
227+
install_file(c, wd, path);
233228
}
234229
}
235230

0 commit comments

Comments
 (0)