@@ -7,6 +7,7 @@ namespace GitVersion.Git;
77internal sealed partial class GitRepository
88{
99 private Lazy < IRepository > ? repositoryLazy ;
10+ private readonly CommitFactory commitFactory = new ( ) ;
1011
1112 private IRepository RepositoryInstance
1213 {
@@ -16,16 +17,17 @@ private IRepository RepositoryInstance
1617 return lazy . Value ;
1718 }
1819 }
20+
1921 public string Path => RepositoryInstance . Info . Path ;
2022 public string WorkingDirectory => RepositoryInstance . Info . WorkingDirectory ;
2123 public bool IsHeadDetached => RepositoryInstance . Info . IsHeadDetached ;
2224 public bool IsShallow => RepositoryInstance . Info . IsShallow ;
23- public IBranch Head => new Branch ( RepositoryInstance . Head , RepositoryInstance . Diff ) ;
25+ public IBranch Head => new Branch ( RepositoryInstance . Head , RepositoryInstance . Diff , this . commitFactory ) ;
2426
25- public ITagCollection Tags => new TagCollection ( RepositoryInstance . Tags , RepositoryInstance . Diff ) ;
27+ public ITagCollection Tags => new TagCollection ( RepositoryInstance . Tags , RepositoryInstance . Diff , this . commitFactory ) ;
2628 public IReferenceCollection Refs => new ReferenceCollection ( RepositoryInstance . Refs ) ;
27- public IBranchCollection Branches => new BranchCollection ( RepositoryInstance . Branches , RepositoryInstance . Diff ) ;
28- public ICommitCollection Commits => new CommitCollection ( RepositoryInstance . Commits , RepositoryInstance . Diff ) ;
29+ public IBranchCollection Branches => new BranchCollection ( RepositoryInstance . Branches , RepositoryInstance . Diff , this . commitFactory ) ;
30+ public ICommitCollection Commits => new CommitCollection ( RepositoryInstance . Commits , RepositoryInstance . Diff , this . commitFactory ) ;
2931 public IRemoteCollection Remotes => new RemoteCollection ( RepositoryInstance . Network . Remotes ) ;
3032
3133 public void DiscoverRepository ( string ? gitDirectory )
@@ -48,7 +50,7 @@ public void DiscoverRepository(string? gitDirectory)
4850 var first = ( Commit ) commit ;
4951 var second = ( Commit ) otherCommit ;
5052 var mergeBase = RepositoryInstance . ObjectDatabase . FindMergeBase ( first , second ) ;
51- return mergeBase == null ? null : new Commit ( mergeBase , RepositoryInstance . Diff ) ;
53+ return mergeBase == null ? null : this . commitFactory . GetOrCreate ( mergeBase , RepositoryInstance . Diff ) ;
5254 } ) ;
5355 }
5456
0 commit comments