@@ -24,6 +24,25 @@ public GitRepoMetadataProvider(IRepository repository, Config configuration)
24
24
this . configuration = configuration ;
25
25
}
26
26
27
+ public static IEnumerable < Tuple < Tag , SemanticVersion > > GetValidVersionTags ( IRepository repository , string tagPrefixRegex , DateTimeOffset ? olderThan = null )
28
+ {
29
+ var tags = new List < Tuple < Tag , SemanticVersion > > ( ) ;
30
+
31
+ foreach ( var tag in repository . Tags )
32
+ {
33
+ if ( olderThan . HasValue && ( ( Commit ) tag . PeeledTarget ( ) ) . When ( ) > olderThan . Value )
34
+ continue ;
35
+
36
+ SemanticVersion semver ;
37
+ if ( SemanticVersion . TryParse ( tag . FriendlyName , tagPrefixRegex , out semver ) )
38
+ {
39
+ tags . Add ( Tuple . Create ( tag , semver ) ) ;
40
+ }
41
+ }
42
+
43
+ return tags ;
44
+ }
45
+
27
46
public IEnumerable < SemanticVersion > GetVersionTagsOnBranch ( Branch branch , string tagPrefixRegex )
28
47
{
29
48
if ( semanticVersionTagsOnBranchCache . ContainsKey ( branch ) )
@@ -34,15 +53,7 @@ public IEnumerable<SemanticVersion> GetVersionTagsOnBranch(Branch branch, string
34
53
35
54
using ( Logger . IndentLog ( string . Format ( "Getting version tags from branch '{0}'." , branch . CanonicalName ) ) )
36
55
{
37
- var tags = new List < Tuple < Tag , SemanticVersion > > ( ) ;
38
- foreach ( var t in this . Repository . Tags )
39
- {
40
- SemanticVersion semver ;
41
- if ( SemanticVersion . TryParse ( t . FriendlyName , tagPrefixRegex , out semver ) )
42
- {
43
- tags . Add ( Tuple . Create ( t , semver ) ) ;
44
- }
45
- }
56
+ var tags = GetValidVersionTags ( this . Repository , tagPrefixRegex ) ;
46
57
47
58
var versionTags = branch . Commits . SelectMany ( c => tags . Where ( t => c . Sha == t . Item1 . Target . Sha ) . Select ( t => t . Item2 ) ) . ToList ( ) ;
48
59
@@ -225,7 +236,7 @@ List<BranchCommit> GetMergeCommitsForBranch(Branch branch, Branch[] excludedBran
225
236
226
237
var currentBranchConfig = configuration . GetConfigForBranch ( branch . NameWithoutRemote ( ) ) ;
227
238
var regexesToCheck = currentBranchConfig == null
228
- ? new [ ] { ".*" } // Match anything if we can't find a branch config
239
+ ? new [ ] { ".*" } // Match anything if we can't find a branch config
229
240
: currentBranchConfig . SourceBranches . Select ( sb => configuration . Branches [ sb ] . Regex ) ;
230
241
var branchMergeBases = Repository . Branches
231
242
. ExcludingBranches ( excludedBranches )
0 commit comments