@@ -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) {
424437fn 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