@@ -279,7 +279,7 @@ func (r *Remote) fetch(ctx context.Context, o *FetchOptions) (storer.ReferenceSt
279
279
}
280
280
}
281
281
282
- updated , err := r .updateLocalReferenceStorage (o .RefSpecs , refs , remoteRefs )
282
+ updated , err := r .updateLocalReferenceStorage (o .RefSpecs , refs , remoteRefs , o . Tags )
283
283
if err != nil {
284
284
return nil , err
285
285
}
@@ -481,10 +481,17 @@ func getHaves(localRefs storer.ReferenceStorer) ([]plumbing.Hash, error) {
481
481
return result , nil
482
482
}
483
483
484
- func calculateRefs (spec []config.RefSpec ,
484
+ const refspecTag = "+refs/tags/*:refs/tags/*"
485
+
486
+ func calculateRefs (
487
+ spec []config.RefSpec ,
485
488
remoteRefs storer.ReferenceStorer ,
486
- tags TagFetchMode ,
489
+ tagMode TagMode ,
487
490
) (memory.ReferenceStorage , error ) {
491
+ if tagMode == AllTags {
492
+ spec = append (spec , refspecTag )
493
+ }
494
+
488
495
iter , err := remoteRefs .IterReferences ()
489
496
if err != nil {
490
497
return nil , err
@@ -493,9 +500,7 @@ func calculateRefs(spec []config.RefSpec,
493
500
refs := make (memory.ReferenceStorage , 0 )
494
501
return refs , iter .ForEach (func (ref * plumbing.Reference ) error {
495
502
if ! config .MatchAny (spec , ref .Name ()) {
496
- if ! ref .Name ().IsTag () || tags != AllTags {
497
- return nil
498
- }
503
+ return nil
499
504
}
500
505
501
506
if ref .Type () == plumbing .SymbolicReference {
@@ -645,6 +650,7 @@ func buildSidebandIfSupported(l *capability.List, reader io.Reader, p sideband.P
645
650
func (r * Remote ) updateLocalReferenceStorage (
646
651
specs []config.RefSpec ,
647
652
fetchedRefs , remoteRefs memory.ReferenceStorage ,
653
+ tagMode TagMode ,
648
654
) (updated bool , err error ) {
649
655
isWildcard := true
650
656
for _ , spec := range specs {
@@ -674,6 +680,10 @@ func (r *Remote) updateLocalReferenceStorage(
674
680
}
675
681
}
676
682
683
+ if tagMode == NoTags {
684
+ return updated , nil
685
+ }
686
+
677
687
tags := fetchedRefs
678
688
if isWildcard {
679
689
tags = remoteRefs
0 commit comments