@@ -460,7 +460,7 @@ impl<'io, 'sess: 'io, 'ctx: 'sess> SessionIo<'sess, 'ctx> {
460
460
}
461
461
DependencySource :: Path ( _) => Ok ( DependencyVersions :: Path ) ,
462
462
DependencySource :: Git ( ref url) => {
463
- let db = self . git_database ( & dep. name , url, force_fetch) . await ?;
463
+ let db = self . git_database ( & dep. name , url, force_fetch, None ) . await ?;
464
464
self . git_versions_func ( db)
465
465
. await
466
466
. map ( DependencyVersions :: Git )
@@ -477,6 +477,7 @@ impl<'io, 'sess: 'io, 'ctx: 'sess> SessionIo<'sess, 'ctx> {
477
477
name : & str ,
478
478
url : & str ,
479
479
force_fetch : bool ,
480
+ fetch_ref : Option < & str > ,
480
481
) -> Result < Git < ' ctx > > {
481
482
// TODO: Make the assembled future shared and keep it in a lookup table.
482
483
// Then use that table to return the future if it already exists.
@@ -533,6 +534,13 @@ impl<'io, 'sess: 'io, 'ctx: 'sess> SessionIo<'sess, 'ctx> {
533
534
. and_then ( |_| git. spawn_with ( |c| c. arg ( "init" ) . arg ( "--bare" ) ) )
534
535
. and_then ( |_| git. spawn_with ( |c| c. arg ( "remote" ) . arg ( "add" ) . arg ( "origin" ) . arg ( url) ) )
535
536
. and_then ( |_| git. fetch ( "origin" ) )
537
+ . and_then ( |_| async {
538
+ if let Some ( reference) = fetch_ref {
539
+ git. fetch_ref ( "origin" , reference) . await
540
+ } else {
541
+ Ok ( ( ) )
542
+ }
543
+ } )
536
544
. await
537
545
. map_err ( move |cause| {
538
546
if url3. contains ( "git@" ) {
@@ -559,6 +567,13 @@ impl<'io, 'sess: 'io, 'ctx: 'sess> SessionIo<'sess, 'ctx> {
559
567
Ok ( ( ) )
560
568
} )
561
569
. and_then ( |_| git. fetch ( "origin" ) )
570
+ . and_then ( |_| async {
571
+ if let Some ( reference) = fetch_ref {
572
+ git. fetch_ref ( "origin" , reference) . await
573
+ } else {
574
+ Ok ( ( ) )
575
+ }
576
+ } )
562
577
. await
563
578
. map_err ( move |cause| {
564
579
if url3. contains ( "git@" ) {
@@ -841,7 +856,7 @@ impl<'io, 'sess: 'io, 'ctx: 'sess> SessionIo<'sess, 'ctx> {
841
856
// branches or tags for shallow clones.
842
857
let tag_name_0 = format ! ( "bender-tmp-{}" , revision) ;
843
858
let tag_name_1 = tag_name_0. clone ( ) ;
844
- let git = self . git_database ( name, url, false ) . await ?;
859
+ let git = self . git_database ( name, url, false , Some ( revision ) ) . await ?;
845
860
git. spawn_with ( move |c| c. arg ( "tag" ) . arg ( tag_name_0) . arg ( revision) . arg ( "--force" ) )
846
861
. map_err ( move |cause| {
847
862
warnln ! ( "Please ensure the commits are available on the remote or run bender update" ) ;
@@ -1041,7 +1056,7 @@ impl<'io, 'sess: 'io, 'ctx: 'sess> SessionIo<'sess, 'ctx> {
1041
1056
( DepSrc :: Git ( url) , DepVer :: Git ( rev) ) => {
1042
1057
let dep_name = self . sess . intern_string ( dep. name . as_str ( ) ) ;
1043
1058
// TODO MICHAERO: May need proper chaining using and_then
1044
- let db = self . git_database ( & dep. name , url, false ) . await ?;
1059
+ let db = self . git_database ( & dep. name , url, false , None ) . await ?;
1045
1060
let entries = db. list_files ( rev, Some ( "Bender.yml" ) ) . await ?;
1046
1061
let data = match entries. into_iter ( ) . next ( ) {
1047
1062
None => Ok ( None ) ,
0 commit comments