@@ -24,19 +24,21 @@ public class ExecuteCoreTests : TestBase
2424 private IFileSystem fileSystem ;
2525 private IEnvironment environment ;
2626 private ILog log ;
27+ private IConfigFileLocator configFileLocator ;
2728
2829 [ SetUp ]
2930 public void SetUp ( )
3031 {
3132 fileSystem = new FileSystem ( ) ;
3233 environment = new TestEnvironment ( ) ;
3334 log = new NullLog ( ) ;
35+ configFileLocator = new DefaultConfigFileLocator ( fileSystem , log ) ;
3436 }
3537
3638 [ Test ]
3739 public void CacheKeySameAfterReNormalizing ( )
3840 {
39- var versionAndBranchFinder = new ExecuteCore ( fileSystem , environment , log ) ;
41+ var versionAndBranchFinder = new ExecuteCore ( fileSystem , environment , log , configFileLocator ) ;
4042
4143 RepositoryScope ( versionAndBranchFinder , ( fixture , vv ) =>
4244 {
@@ -58,7 +60,7 @@ public void CacheKeySameAfterReNormalizing()
5860 [ Description ( "LibGit2Sharp fails here when running under Mono" ) ]
5961 public void CacheKeyForWorktree ( )
6062 {
61- var versionAndBranchFinder = new ExecuteCore ( fileSystem , environment , log ) ;
63+ var versionAndBranchFinder = new ExecuteCore ( fileSystem , environment , log , configFileLocator ) ;
6264
6365 RepositoryScope ( versionAndBranchFinder , ( fixture , vv ) =>
6466 {
@@ -124,12 +126,12 @@ public void CacheFileExistsOnDisk()
124126 var logAppender = new TestLogAppender ( Action ) ;
125127 log = new Log ( logAppender ) ;
126128
127- var versionAndBranchFinder = new ExecuteCore ( fileSystem , environment , log ) ;
129+ var versionAndBranchFinder = new ExecuteCore ( fileSystem , environment , log , configFileLocator ) ;
128130
129131 RepositoryScope ( versionAndBranchFinder , ( fixture , vv ) =>
130132 {
131133 fileSystem . WriteAllText ( vv . FileName , versionCacheFileContent ) ;
132- vv = versionAndBranchFinder . ExecuteGitVersion ( null , null , null , null , false , fixture . RepositoryPath , null ) ;
134+ vv = versionAndBranchFinder . ExecuteGitVersion ( new Arguments { TargetPath = fixture . RepositoryPath } ) ;
133135 vv . AssemblySemVer . ShouldBe ( "4.10.3.0" ) ;
134136 } ) ;
135137
@@ -173,7 +175,7 @@ public void CacheFileExistsOnDiskWhenOverrideConfigIsSpecifiedVersionShouldBeDyn
173175CommitDate: 2015-11-10
174176" ;
175177
176- var versionAndBranchFinder = new ExecuteCore ( fileSystem , environment , log ) ;
178+ var versionAndBranchFinder = new ExecuteCore ( fileSystem , environment , log , configFileLocator ) ;
177179
178180 RepositoryScope ( versionAndBranchFinder , ( fixture , vv ) =>
179181 {
@@ -184,7 +186,7 @@ public void CacheFileExistsOnDiskWhenOverrideConfigIsSpecifiedVersionShouldBeDyn
184186
185187 var cacheDirectoryTimestamp = fileSystem . GetLastDirectoryWrite ( cacheDirectory ) ;
186188
187- vv = versionAndBranchFinder . ExecuteGitVersion ( null , null , null , null , false , fixture . RepositoryPath , null , new Config ( ) { TagPrefix = "prefix" } ) ;
189+ vv = versionAndBranchFinder . ExecuteGitVersion ( new Arguments { TargetPath = fixture . RepositoryPath , OverrideConfig = new Config { TagPrefix = "prefix" } } ) ;
188190
189191 vv . AssemblySemVer . ShouldBe ( "0.1.0.0" ) ;
190192
@@ -204,7 +206,7 @@ public void CacheFileIsMissing()
204206 var logAppender = new TestLogAppender ( Action ) ;
205207 log = new Log ( logAppender ) ;
206208
207- var executeCore = new ExecuteCore ( fileSystem , environment , log ) ;
209+ var executeCore = new ExecuteCore ( fileSystem , environment , log , configFileLocator ) ;
208210
209211 RepositoryScope ( executeCore ) ;
210212 var logsMessages = stringBuilder . ToString ( ) ;
@@ -248,18 +250,19 @@ public void ConfigChangeInvalidatesCache()
248250CommitDate: 2015-11-10
249251" ;
250252
251- var versionAndBranchFinder = new ExecuteCore ( fileSystem , environment , log ) ;
253+ var versionAndBranchFinder = new ExecuteCore ( fileSystem , environment , log , configFileLocator ) ;
252254
253255 RepositoryScope ( versionAndBranchFinder , ( fixture , vv ) =>
254256 {
255257 fileSystem . WriteAllText ( vv . FileName , versionCacheFileContent ) ;
256- vv = versionAndBranchFinder . ExecuteGitVersion ( null , null , null , null , false , fixture . RepositoryPath , null ) ;
258+ var arguments = new Arguments { TargetPath = fixture . RepositoryPath } ;
259+ vv = versionAndBranchFinder . ExecuteGitVersion ( arguments ) ;
257260 vv . AssemblySemVer . ShouldBe ( "4.10.3.0" ) ;
258261
259262 var configPath = Path . Combine ( fixture . RepositoryPath , "GitVersionConfig.yaml" ) ;
260263 fileSystem . WriteAllText ( configPath , "next-version: 5.0" ) ;
261264
262- vv = versionAndBranchFinder . ExecuteGitVersion ( null , null , null , null , false , fixture . RepositoryPath , null ) ;
265+ vv = versionAndBranchFinder . ExecuteGitVersion ( arguments ) ;
263266 vv . AssemblySemVer . ShouldBe ( "5.0.0.0" ) ;
264267 } ) ;
265268 }
@@ -300,15 +303,18 @@ public void NoCacheBypassesCache()
300303CommitDate: 2015-11-10
301304" ;
302305
303- var versionAndBranchFinder = new ExecuteCore ( fileSystem , environment , log ) ;
306+ var versionAndBranchFinder = new ExecuteCore ( fileSystem , environment , log , configFileLocator ) ;
304307
305308 RepositoryScope ( versionAndBranchFinder , ( fixture , vv ) =>
306309 {
310+ var arguments = new Arguments { TargetPath = fixture . RepositoryPath } ;
311+
307312 fileSystem . WriteAllText ( vv . FileName , versionCacheFileContent ) ;
308- vv = versionAndBranchFinder . ExecuteGitVersion ( null , null , null , null , false , fixture . RepositoryPath , null ) ;
313+ vv = versionAndBranchFinder . ExecuteGitVersion ( arguments ) ;
309314 vv . AssemblySemVer . ShouldBe ( "4.10.3.0" ) ;
310315
311- vv = versionAndBranchFinder . ExecuteGitVersion ( null , null , null , null , false , fixture . RepositoryPath , null , noCache : true ) ;
316+ arguments . NoCache = true ;
317+ vv = versionAndBranchFinder . ExecuteGitVersion ( arguments ) ;
312318 vv . AssemblySemVer . ShouldBe ( "0.1.0.0" ) ;
313319 } ) ;
314320 }
@@ -317,11 +323,13 @@ public void NoCacheBypassesCache()
317323 [ Test ]
318324 public void WorkingDirectoryWithoutGit ( )
319325 {
320- var versionAndBranchFinder = new ExecuteCore ( fileSystem , environment , log ) ;
326+ var versionAndBranchFinder = new ExecuteCore ( fileSystem , environment , log , configFileLocator ) ;
321327
322328 RepositoryScope ( versionAndBranchFinder , ( fixture , vv ) =>
323329 {
324- var exception = Assert . Throws < DirectoryNotFoundException > ( ( ) => versionAndBranchFinder . ExecuteGitVersion ( null , null , null , null , false , Environment . SystemDirectory , null ) ) ;
330+ var arguments = new Arguments { TargetPath = Environment . SystemDirectory } ;
331+
332+ var exception = Assert . Throws < DirectoryNotFoundException > ( ( ) => versionAndBranchFinder . ExecuteGitVersion ( arguments ) ) ;
325333 exception . Message . ShouldContain ( "Can't find the .git directory in" ) ;
326334 } ) ;
327335 }
@@ -331,7 +339,7 @@ public void WorkingDirectoryWithoutGit()
331339 [ Description ( "LibGit2Sharp fails when running under Mono" ) ]
332340 public void GetProjectRootDirectory_WorkingDirectoryWithWorktree ( )
333341 {
334- var versionAndBranchFinder = new ExecuteCore ( fileSystem , environment , log ) ;
342+ var versionAndBranchFinder = new ExecuteCore ( fileSystem , environment , log , configFileLocator ) ;
335343
336344 RepositoryScope ( versionAndBranchFinder , ( fixture , vv ) =>
337345 {
@@ -356,7 +364,7 @@ public void GetProjectRootDirectory_WorkingDirectoryWithWorktree()
356364 [ Test ]
357365 public void GetProjectRootDirectory_NoWorktree ( )
358366 {
359- var versionAndBranchFinder = new ExecuteCore ( fileSystem , environment , log ) ;
367+ var versionAndBranchFinder = new ExecuteCore ( fileSystem , environment , log , configFileLocator ) ;
360368
361369 RepositoryScope ( versionAndBranchFinder , ( fixture , vv ) =>
362370 {
@@ -370,18 +378,25 @@ public void GetProjectRootDirectory_NoWorktree()
370378 [ Test ]
371379 public void DynamicRepositoriesShouldNotErrorWithFailedToFindGitDirectory ( )
372380 {
373- var versionAndBranchFinder = new ExecuteCore ( fileSystem , environment , log ) ;
381+ var versionAndBranchFinder = new ExecuteCore ( fileSystem , environment , log , configFileLocator ) ;
374382
375383 RepositoryScope ( versionAndBranchFinder , ( fixture , vv ) =>
376384 {
377- versionAndBranchFinder . ExecuteGitVersion ( "https://github.com/GitTools/GitVersion.git" , null , new Authentication ( ) , "refs/head/master" , false , fixture . RepositoryPath , null ) ;
385+ var arguments = new Arguments
386+ {
387+ TargetPath = fixture . RepositoryPath ,
388+ TargetUrl = "https://github.com/GitTools/GitVersion.git" ,
389+ TargetBranch = "refs/head/master"
390+ } ;
391+
392+ versionAndBranchFinder . ExecuteGitVersion ( arguments ) ;
378393 } ) ;
379394 }
380395
381396 [ Test ]
382397 public void GetDotGitDirectory_NoWorktree ( )
383398 {
384- var versionAndBranchFinder = new ExecuteCore ( fileSystem , environment , log ) ;
399+ var versionAndBranchFinder = new ExecuteCore ( fileSystem , environment , log , configFileLocator ) ;
385400
386401 RepositoryScope ( versionAndBranchFinder , ( fixture , vv ) =>
387402 {
@@ -397,7 +412,7 @@ public void GetDotGitDirectory_NoWorktree()
397412 [ Description ( "LibGit2Sharp fails when running under Mono" ) ]
398413 public void GetDotGitDirectory_Worktree ( )
399414 {
400- var versionAndBranchFinder = new ExecuteCore ( fileSystem , environment , log ) ;
415+ var versionAndBranchFinder = new ExecuteCore ( fileSystem , environment , log , configFileLocator ) ;
401416
402417 RepositoryScope ( versionAndBranchFinder , ( fixture , vv ) =>
403418 {
@@ -428,9 +443,11 @@ private void RepositoryScope(ExecuteCore executeCore, Action<EmptyRepositoryFixt
428443 environment . SetEnvironmentVariable ( TravisCI . EnvironmentVariableName , null ) ;
429444 environment . SetEnvironmentVariable ( AzurePipelines . EnvironmentVariableName , null ) ;
430445
446+
431447 using var fixture = new EmptyRepositoryFixture ( ) ;
448+ var arguments = new Arguments { TargetPath = fixture . RepositoryPath } ;
432449 fixture . Repository . MakeACommit ( ) ;
433- var vv = executeCore . ExecuteGitVersion ( null , null , null , null , false , fixture . RepositoryPath , null ) ;
450+ var vv = executeCore . ExecuteGitVersion ( arguments ) ;
434451
435452 vv . AssemblySemVer . ShouldBe ( "0.1.0.0" ) ;
436453 vv . FileName . ShouldNotBeNullOrEmpty ( ) ;
0 commit comments