11using GitVersion . Common ;
22using GitVersion . Configuration ;
33using GitVersion . Extensions ;
4- using GitVersion . Model . Configuration ;
54
65namespace GitVersion . VersionCalculation ;
76
@@ -26,14 +25,16 @@ public class TrackReleaseBranchesVersionStrategy : VersionStrategyBase
2625 private readonly IRepositoryStore repositoryStore ;
2726 private readonly VersionInBranchNameVersionStrategy releaseVersionStrategy ;
2827 private readonly TaggedCommitVersionStrategy taggedCommitVersionStrategy ;
28+ private readonly Lazy < GitVersionContext > context ;
29+
2930
3031 public TrackReleaseBranchesVersionStrategy ( IRepositoryStore repositoryStore , Lazy < GitVersionContext > versionContext )
3132 : base ( versionContext )
3233 {
3334 this . repositoryStore = repositoryStore . NotNull ( ) ;
34-
3535 this . releaseVersionStrategy = new VersionInBranchNameVersionStrategy ( repositoryStore , versionContext ) ;
3636 this . taggedCommitVersionStrategy = new TaggedCommitVersionStrategy ( repositoryStore , versionContext ) ;
37+ this . context = versionContext . NotNull ( ) ;
3738 }
3839
3940 public override IEnumerable < BaseVersion > GetVersions ( ) =>
@@ -43,9 +44,8 @@ public override IEnumerable<BaseVersion> GetVersions() =>
4344
4445 private IEnumerable < BaseVersion > MainTagsVersions ( )
4546 {
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 ) ;
4949
5050 return main != null
5151 ? this . taggedCommitVersionStrategy . GetTaggedVersions ( main , null )
0 commit comments