Skip to content

Commit c1f6779

Browse files
committed
cleanup
1 parent b5492cd commit c1f6779

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/GitVersionCore/VersionCalculation/Cache/GitVersionCacheKeyFactory.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
using GitVersion.Configuration;
99
using GitVersion.Logging;
1010
using GitVersion.Model.Configuration;
11-
using LibGit2Sharp;
1211
using Microsoft.Extensions.Options;
1312

1413
namespace GitVersion.VersionCalculation.Cache
@@ -19,13 +18,17 @@ public class GitVersionCacheKeyFactory : IGitVersionCacheKeyFactory
1918
private readonly ILog log;
2019
private readonly IOptions<GitVersionOptions> options;
2120
private readonly IConfigFileLocator configFileLocator;
21+
private readonly IGitRepository gitRepository;
2222

23-
public GitVersionCacheKeyFactory(IFileSystem fileSystem, ILog log, IOptions<GitVersionOptions> options, IConfigFileLocator configFileLocator)
23+
public GitVersionCacheKeyFactory(IFileSystem fileSystem, ILog log,
24+
IOptions<GitVersionOptions> options, IConfigFileLocator configFileLocator,
25+
IGitRepository gitRepository)
2426
{
2527
this.fileSystem = fileSystem ?? throw new ArgumentNullException(nameof(fileSystem));
2628
this.log = log ?? throw new ArgumentNullException(nameof(log));
2729
this.options = options ?? throw new ArgumentNullException(nameof(options));
2830
this.configFileLocator = configFileLocator ?? throw new ArgumentNullException(nameof(configFileLocator));
31+
this.gitRepository = gitRepository ?? throw new ArgumentNullException(nameof(gitRepository));
2932
}
3033

3134
public GitVersionCacheKey Create(Config overrideConfig)
@@ -141,9 +144,7 @@ private List<string> CalculateDirectoryContents(string root)
141144

142145
private string GetRepositorySnapshotHash()
143146
{
144-
using var repo = new Repository(options.Value.GitRootPath);
145-
146-
var head = repo.Head;
147+
var head = gitRepository.Head;
147148
if (head.Tip == null)
148149
{
149150
return head.CanonicalName;

0 commit comments

Comments
 (0)