11using GitVersion . Common ;
22using GitVersion . Extensions ;
33using GitVersion . Git ;
4+ using Microsoft . Extensions . Logging ;
45using GitVersion . Logging ;
56
67namespace GitVersion ;
78
8- internal class BranchesContainingCommitFinder ( IRepositoryStore repositoryStore , ILog log )
9+ internal class BranchesContainingCommitFinder ( IRepositoryStore repositoryStore , ILogger < BranchesContainingCommitFinder > logger )
910{
10- private readonly ILog log = log . NotNull ( ) ;
11+ private readonly ILogger < BranchesContainingCommitFinder > logger = log . NotNull ( ) ;
1112 private readonly IRepositoryStore repositoryStore = repositoryStore . NotNull ( ) ;
1213
1314 public IEnumerable < IBranch > GetBranchesContainingCommit ( ICommit commit , IEnumerable < IBranch > ? branches = null , bool onlyTrackedBranches = false )
@@ -23,16 +24,16 @@ public IEnumerable<IBranch> GetBranchesContainingCommit(ICommit commit, IEnumera
2324
2425 private IEnumerable < IBranch > InnerGetBranchesContainingCommit ( ICommit commit , IEnumerable < IBranch > branches , bool onlyTrackedBranches )
2526 {
26- using ( log . IndentLog ( $ "Getting branches containing the commit '{ commit . Id } '.") )
27+ using ( logger . IndentLog ( $ "Getting branches containing the commit '{ commit . Id } '.") )
2728 {
2829 var directBranchHasBeenFound = false ;
29- log . Info ( "Trying to find direct branches." ) ;
30+ logger . LogInformation ( "Trying to find direct branches." ) ;
3031 // TODO: It looks wasteful looping through the branches twice. Can't these loops be merged somehow? @asbjornu
3132 var branchList = branches . ToList ( ) ;
3233 foreach ( var branch in branchList . Where ( branch => BranchTipIsNullOrCommit ( branch , commit ) && ! IncludeTrackedBranches ( branch , onlyTrackedBranches ) ) )
3334 {
3435 directBranchHasBeenFound = true ;
35- log . Info ( $ "Direct branch found: '{ branch } '.") ;
36+ logger . LogInformation ( $ "Direct branch found: '{ branch } '.") ;
3637 yield return branch ;
3738 }
3839
@@ -41,20 +42,20 @@ private IEnumerable<IBranch> InnerGetBranchesContainingCommit(ICommit commit, IE
4142 yield break ;
4243 }
4344
44- log . Info ( $ "No direct branches found, searching through { ( onlyTrackedBranches ? "tracked" : "all" ) } branches.") ;
45+ logger . LogInformation ( $ "No direct branches found, searching through { ( onlyTrackedBranches ? "tracked" : "all" ) } branches.") ;
4546 foreach ( var branch in branchList . Where ( b => IncludeTrackedBranches ( b , onlyTrackedBranches ) ) )
4647 {
47- log . Info ( $ "Searching for commits reachable from '{ branch } '.") ;
48+ logger . LogInformation ( $ "Searching for commits reachable from '{ branch } '.") ;
4849
4950 var commits = this . repositoryStore . GetCommitsReacheableFrom ( commit , branch ) ;
5051
5152 if ( ! commits . Any ( ) )
5253 {
53- log . Info ( $ "The branch '{ branch } ' has no matching commits.") ;
54+ logger . LogInformation ( $ "The branch '{ branch } ' has no matching commits.") ;
5455 continue ;
5556 }
5657
57- log . Info ( $ "The branch '{ branch } ' has a matching commit.") ;
58+ logger . LogInformation ( $ "The branch '{ branch } ' has a matching commit.") ;
5859 yield return branch ;
5960 }
6061 }
0 commit comments