@@ -31,6 +31,7 @@ type package = {
31
31
uuid: str,
32
32
url: str,
33
33
method: str,
34
+ ref : option:: t<str>,
34
35
tags: [ str]
35
36
} ;
36
37
@@ -242,6 +243,11 @@ fn load_one_source_package(&src: source, p: map::hashmap<str, json::json>) {
242
243
}
243
244
} ;
244
245
246
+ let ref = alt p. find ( "ref" ) {
247
+ some ( json:: string ( _n) ) { some ( _n) }
248
+ _ { none }
249
+ } ;
250
+
245
251
let tags = [ ] ;
246
252
alt p. find ( "tags" ) {
247
253
some ( json:: list ( js) ) {
@@ -260,6 +266,7 @@ fn load_one_source_package(&src: source, p: map::hashmap<str, json::json>) {
260
266
uuid: uuid,
261
267
url: url,
262
268
method: method,
269
+ ref: ref ,
263
270
tags: tags
264
271
} ) ;
265
272
log " Loaded package: " + src. name + "/" + name;
@@ -398,8 +405,14 @@ fn install_source(c: cargo, path: str) {
398
405
}
399
406
}
400
407
401
- fn install_git ( c : cargo , wd : str , url : str ) {
408
+ fn install_git ( c : cargo , wd : str , url : str , ref : option :: t < str > ) {
402
409
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
+
403
416
install_source ( c, wd) ;
404
417
}
405
418
@@ -424,7 +437,7 @@ fn install_file(c: cargo, wd: str, path: str) {
424
437
fn install_package ( c : cargo , wd : str , pkg : package ) {
425
438
info ( "Installing with " + pkg. method + " from " + pkg. url + "..." ) ;
426
439
if pkg. method == "git" {
427
- install_git ( c, wd, pkg. url ) ;
440
+ install_git ( c, wd, pkg. url , pkg . ref ) ;
428
441
} else if pkg. method == "http" {
429
442
install_curl ( c, wd, pkg. url ) ;
430
443
} else if pkg. method == "file" {
0 commit comments