@@ -19,21 +19,31 @@ public override IEnumerable<BaseVersion> GetVersions(GitVersionContext context)
1919
2020 public IEnumerable < BaseVersion > GetTaggedVersions ( GitVersionContext context , Branch currentBranch , DateTimeOffset ? olderThan )
2121 {
22- var allTags = context . Repository . Tags
23- . Where ( tag => ! olderThan . HasValue || ( ( Commit ) tag . PeeledTarget ( ) ) . When ( ) <= olderThan . Value )
24- . ToList ( ) ;
22+ var allTags = new List < Tuple < Tag , SemanticVersion > > ( ) ;
23+ foreach ( var tag in context . Repository . Tags )
24+ {
25+ if ( olderThan . HasValue && ( ( Commit ) tag . PeeledTarget ( ) ) . When ( ) > olderThan . Value )
26+ continue ;
27+
28+ SemanticVersion version ;
29+
30+ if ( ! SemanticVersion . TryParse ( tag . FriendlyName , context . Configuration . GitTagPrefix , out version ) )
31+ {
32+ continue ;
33+ }
34+
35+ allTags . Add ( Tuple . Create ( tag , version ) ) ;
36+ }
37+
2538 var tagsOnBranch = currentBranch
2639 . Commits
27- . SelectMany ( commit => { return allTags . Where ( t => IsValidTag ( t , commit ) ) ; } )
40+ . SelectMany ( commit => { return allTags . Where ( t => IsValidTag ( t . Item1 , commit ) ) ; } )
2841 . Select ( t =>
2942 {
30- SemanticVersion version ;
31- if ( SemanticVersion . TryParse ( t . FriendlyName , context . Configuration . GitTagPrefix , out version ) )
32- {
33- var commit = t . PeeledTarget ( ) as Commit ;
34- if ( commit != null )
35- return new VersionTaggedCommit ( commit , version , t . FriendlyName ) ;
36- }
43+ var commit = t . Item1 . PeeledTarget ( ) as Commit ;
44+ if ( commit != null )
45+ return new VersionTaggedCommit ( commit , t . Item2 , t . Item1 . FriendlyName ) ;
46+
3747 return null ;
3848 } )
3949 . Where ( a => a != null )
0 commit comments