5
5
6
6
namespace GitVersion . Core ;
7
7
8
- internal interface IBranchRepository
9
- {
10
- IEnumerable < IBranch > GetMainlineBranches ( params IBranch [ ] excludeBranches ) ;
11
-
12
- IEnumerable < IBranch > GetReleaseBranches ( params IBranch [ ] excludeBranches ) ;
13
- }
14
-
15
- internal sealed class BranchRepository : IBranchRepository
16
- {
17
- private GitVersionContext VersionContext => this . versionContextLazy . Value ;
18
- private readonly Lazy < GitVersionContext > versionContextLazy ;
19
-
20
- private readonly IGitRepository gitRepository ;
21
-
22
- public BranchRepository ( Lazy < GitVersionContext > versionContext , IGitRepository gitRepository )
23
- {
24
- this . versionContextLazy = versionContext . NotNull ( ) ;
25
- this . gitRepository = gitRepository . NotNull ( ) ;
26
- }
27
-
28
- public IEnumerable < IBranch > GetMainlineBranches ( params IBranch [ ] excludeBranches )
29
- => GetBranchesWhere ( new HashSet < IBranch > ( excludeBranches ) , configuration => configuration . IsMainline == true ) ;
30
-
31
- public IEnumerable < IBranch > GetReleaseBranches ( params IBranch [ ] excludeBranches )
32
- => GetBranchesWhere ( new HashSet < IBranch > ( excludeBranches ) , configuration => configuration . IsReleaseBranch == true ) ;
33
-
34
- private IEnumerable < IBranch > GetBranchesWhere ( HashSet < IBranch > excludeBranches , Func < IBranchConfiguration , bool > predicate )
35
- {
36
- predicate . NotNull ( ) ;
37
-
38
- foreach ( var branch in this . gitRepository . Branches )
39
- {
40
- if ( ! excludeBranches . Contains ( branch ) )
41
- {
42
- var branchConfiguration = VersionContext . Configuration . GetBranchConfiguration ( branch . Name ) ;
43
- if ( predicate ( branchConfiguration ) )
44
- {
45
- yield return branch ;
46
- }
47
- }
48
- }
49
- }
50
- }
51
-
52
- internal interface ITaggedSemanticVersionRepository
53
- {
54
- ILookup < ICommit , SemanticVersionWithTag > GetTaggedSemanticVersions ( IBranch branch , EffectiveConfiguration configuration ) ;
55
-
56
- ILookup < ICommit , SemanticVersionWithTag > GetAllTaggedSemanticVersions ( string ? tagPrefix , SemanticVersionFormat format ) ;
57
-
58
- ILookup < ICommit , SemanticVersionWithTag > GetTaggedSemanticVersionsOfBranch (
59
- IBranch branch , string ? tagPrefix , SemanticVersionFormat format
60
- ) ;
61
-
62
- ILookup < ICommit , SemanticVersionWithTag > GetTaggedSemanticVersionsOfMergeTarget (
63
- IBranch branch , string ? tagPrefix , SemanticVersionFormat format
64
- ) ;
65
-
66
- ILookup < ICommit , SemanticVersionWithTag > GetTaggedSemanticVersionsOfMainlineBranches (
67
- string ? tagPrefix , SemanticVersionFormat format , params IBranch [ ] excludeBranches
68
- ) ;
69
-
70
- ILookup < ICommit , SemanticVersionWithTag > GetTaggedSemanticVersionsOfReleaseBranches (
71
- string ? tagPrefix , SemanticVersionFormat format , params IBranch [ ] excludeBranches
72
- ) ;
73
- }
74
-
75
8
internal sealed class TaggedSemanticVersionRepository : ITaggedSemanticVersionRepository
76
9
{
77
10
private readonly ILog log ;
@@ -173,7 +106,7 @@ public ILookup<ICommit, SemanticVersionWithTag> GetTaggedSemanticVersions(IBranc
173
106
}
174
107
175
108
private readonly ConcurrentDictionary < ( string , SemanticVersionFormat ) , ILookup < ICommit , SemanticVersionWithTag > >
176
- getAllTaggedSemanticVersionsCache = new ( ) ;
109
+ allTaggedSemanticVersionsCache = new ( ) ;
177
110
178
111
public ILookup < ICommit , SemanticVersionWithTag > GetAllTaggedSemanticVersions ( string ? tagPrefix , SemanticVersionFormat format )
179
112
{
@@ -193,7 +126,7 @@ IEnumerable<SemanticVersionWithTag> GetElements()
193
126
}
194
127
195
128
bool isCached = true ;
196
- var result = getAllTaggedSemanticVersionsCache . GetOrAdd ( new ( tagPrefix , format ) , _ =>
129
+ var result = allTaggedSemanticVersionsCache . GetOrAdd ( new ( tagPrefix , format ) , _ =>
197
130
{
198
131
isCached = false ;
199
132
return GetElements ( ) . ToLookup ( element => element . Tag . Commit , element => element ) ;
@@ -208,7 +141,7 @@ IEnumerable<SemanticVersionWithTag> GetElements()
208
141
}
209
142
210
143
private readonly ConcurrentDictionary < ( IBranch , string , SemanticVersionFormat ) , ILookup < ICommit , SemanticVersionWithTag > >
211
- getTaggedSemanticVersionsOfBranchCache = new ( ) ;
144
+ taggedSemanticVersionsOfBranchCache = new ( ) ;
212
145
213
146
public ILookup < ICommit , SemanticVersionWithTag > GetTaggedSemanticVersionsOfBranch (
214
147
IBranch branch , string ? tagPrefix , SemanticVersionFormat format )
@@ -234,7 +167,7 @@ IEnumerable<SemanticVersionWithTag> GetElements()
234
167
}
235
168
236
169
bool isCached = true ;
237
- var result = getTaggedSemanticVersionsOfBranchCache . GetOrAdd ( new ( branch , tagPrefix , format ) , _ =>
170
+ var result = taggedSemanticVersionsOfBranchCache . GetOrAdd ( new ( branch , tagPrefix , format ) , _ =>
238
171
{
239
172
isCached = false ;
240
173
var semanticVersions = GetElements ( ) ;
@@ -253,7 +186,7 @@ IEnumerable<SemanticVersionWithTag> GetElements()
253
186
}
254
187
255
188
private readonly ConcurrentDictionary < ( IBranch , string , SemanticVersionFormat ) , ILookup < ICommit , SemanticVersionWithTag > >
256
- getTaggedSemanticVersionsOfMergeTargetCache = new ( ) ;
189
+ taggedSemanticVersionsOfMergeTargetCache = new ( ) ;
257
190
258
191
public ILookup < ICommit , SemanticVersionWithTag > GetTaggedSemanticVersionsOfMergeTarget (
259
192
IBranch branch , string ? tagPrefix , SemanticVersionFormat format )
@@ -279,7 +212,7 @@ public ILookup<ICommit, SemanticVersionWithTag> GetTaggedSemanticVersionsOfMerge
279
212
}
280
213
281
214
bool isCached = true ;
282
- var result = getTaggedSemanticVersionsOfMergeTargetCache . GetOrAdd ( new ( branch , tagPrefix , format ) , _ =>
215
+ var result = taggedSemanticVersionsOfMergeTargetCache . GetOrAdd ( new ( branch , tagPrefix , format ) , _ =>
283
216
{
284
217
isCached = false ;
285
218
return GetElements ( ) . ToLookup ( element => element . Item1 , element => element . Item2 ) ;
0 commit comments