1
1
using GitVersion . Common ;
2
2
using GitVersion . Configuration ;
3
3
using GitVersion . Extensions ;
4
- using GitVersion . Model . Configuration ;
5
4
6
5
namespace GitVersion . VersionCalculation ;
7
6
@@ -26,14 +25,16 @@ public class TrackReleaseBranchesVersionStrategy : VersionStrategyBase
26
25
private readonly IRepositoryStore repositoryStore ;
27
26
private readonly VersionInBranchNameVersionStrategy releaseVersionStrategy ;
28
27
private readonly TaggedCommitVersionStrategy taggedCommitVersionStrategy ;
28
+ private readonly Lazy < GitVersionContext > context ;
29
+
29
30
30
31
public TrackReleaseBranchesVersionStrategy ( IRepositoryStore repositoryStore , Lazy < GitVersionContext > versionContext )
31
32
: base ( versionContext )
32
33
{
33
34
this . repositoryStore = repositoryStore . NotNull ( ) ;
34
-
35
35
this . releaseVersionStrategy = new VersionInBranchNameVersionStrategy ( repositoryStore , versionContext ) ;
36
36
this . taggedCommitVersionStrategy = new TaggedCommitVersionStrategy ( repositoryStore , versionContext ) ;
37
+ this . context = versionContext . NotNull ( ) ;
37
38
}
38
39
39
40
public override IEnumerable < BaseVersion > GetVersions ( ) =>
@@ -43,9 +44,8 @@ public override IEnumerable<BaseVersion> GetVersions() =>
43
44
44
45
private IEnumerable < BaseVersion > MainTagsVersions ( )
45
46
{
46
- var main = this . repositoryStore . FindBranch ( Config . MainBranchKey )
47
- // For compatibility reason try to find `master` if `main` cannot be found
48
- ?? this . repositoryStore . FindBranch ( Config . MasterBranchKey ) ;
47
+ var configuration = this . context . Value . Configuration . Configuration ;
48
+ var main = this . repositoryStore . FindMainBranch ( configuration ) ;
49
49
50
50
return main != null
51
51
? this . taggedCommitVersionStrategy . GetTaggedVersions ( main , null )
0 commit comments