@@ -24,19 +24,21 @@ public class ExecuteCoreTests : TestBase
24
24
private IFileSystem fileSystem ;
25
25
private IEnvironment environment ;
26
26
private ILog log ;
27
+ private IConfigFileLocator configFileLocator ;
27
28
28
29
[ SetUp ]
29
30
public void SetUp ( )
30
31
{
31
32
fileSystem = new FileSystem ( ) ;
32
33
environment = new TestEnvironment ( ) ;
33
34
log = new NullLog ( ) ;
35
+ configFileLocator = new DefaultConfigFileLocator ( fileSystem , log ) ;
34
36
}
35
37
36
38
[ Test ]
37
39
public void CacheKeySameAfterReNormalizing ( )
38
40
{
39
- var versionAndBranchFinder = new ExecuteCore ( fileSystem , environment , log ) ;
41
+ var versionAndBranchFinder = new ExecuteCore ( fileSystem , environment , log , configFileLocator ) ;
40
42
41
43
RepositoryScope ( versionAndBranchFinder , ( fixture , vv ) =>
42
44
{
@@ -58,7 +60,7 @@ public void CacheKeySameAfterReNormalizing()
58
60
[ Description ( "LibGit2Sharp fails here when running under Mono" ) ]
59
61
public void CacheKeyForWorktree ( )
60
62
{
61
- var versionAndBranchFinder = new ExecuteCore ( fileSystem , environment , log ) ;
63
+ var versionAndBranchFinder = new ExecuteCore ( fileSystem , environment , log , configFileLocator ) ;
62
64
63
65
RepositoryScope ( versionAndBranchFinder , ( fixture , vv ) =>
64
66
{
@@ -124,12 +126,12 @@ public void CacheFileExistsOnDisk()
124
126
var logAppender = new TestLogAppender ( Action ) ;
125
127
log = new Log ( logAppender ) ;
126
128
127
- var versionAndBranchFinder = new ExecuteCore ( fileSystem , environment , log ) ;
129
+ var versionAndBranchFinder = new ExecuteCore ( fileSystem , environment , log , configFileLocator ) ;
128
130
129
131
RepositoryScope ( versionAndBranchFinder , ( fixture , vv ) =>
130
132
{
131
133
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 } ) ;
133
135
vv . AssemblySemVer . ShouldBe ( "4.10.3.0" ) ;
134
136
} ) ;
135
137
@@ -173,7 +175,7 @@ public void CacheFileExistsOnDiskWhenOverrideConfigIsSpecifiedVersionShouldBeDyn
173
175
CommitDate: 2015-11-10
174
176
" ;
175
177
176
- var versionAndBranchFinder = new ExecuteCore ( fileSystem , environment , log ) ;
178
+ var versionAndBranchFinder = new ExecuteCore ( fileSystem , environment , log , configFileLocator ) ;
177
179
178
180
RepositoryScope ( versionAndBranchFinder , ( fixture , vv ) =>
179
181
{
@@ -184,7 +186,7 @@ public void CacheFileExistsOnDiskWhenOverrideConfigIsSpecifiedVersionShouldBeDyn
184
186
185
187
var cacheDirectoryTimestamp = fileSystem . GetLastDirectoryWrite ( cacheDirectory ) ;
186
188
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" } } ) ;
188
190
189
191
vv . AssemblySemVer . ShouldBe ( "0.1.0.0" ) ;
190
192
@@ -204,7 +206,7 @@ public void CacheFileIsMissing()
204
206
var logAppender = new TestLogAppender ( Action ) ;
205
207
log = new Log ( logAppender ) ;
206
208
207
- var executeCore = new ExecuteCore ( fileSystem , environment , log ) ;
209
+ var executeCore = new ExecuteCore ( fileSystem , environment , log , configFileLocator ) ;
208
210
209
211
RepositoryScope ( executeCore ) ;
210
212
var logsMessages = stringBuilder . ToString ( ) ;
@@ -248,18 +250,19 @@ public void ConfigChangeInvalidatesCache()
248
250
CommitDate: 2015-11-10
249
251
" ;
250
252
251
- var versionAndBranchFinder = new ExecuteCore ( fileSystem , environment , log ) ;
253
+ var versionAndBranchFinder = new ExecuteCore ( fileSystem , environment , log , configFileLocator ) ;
252
254
253
255
RepositoryScope ( versionAndBranchFinder , ( fixture , vv ) =>
254
256
{
255
257
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 ) ;
257
260
vv . AssemblySemVer . ShouldBe ( "4.10.3.0" ) ;
258
261
259
262
var configPath = Path . Combine ( fixture . RepositoryPath , "GitVersionConfig.yaml" ) ;
260
263
fileSystem . WriteAllText ( configPath , "next-version: 5.0" ) ;
261
264
262
- vv = versionAndBranchFinder . ExecuteGitVersion ( null , null , null , null , false , fixture . RepositoryPath , null ) ;
265
+ vv = versionAndBranchFinder . ExecuteGitVersion ( arguments ) ;
263
266
vv . AssemblySemVer . ShouldBe ( "5.0.0.0" ) ;
264
267
} ) ;
265
268
}
@@ -300,15 +303,18 @@ public void NoCacheBypassesCache()
300
303
CommitDate: 2015-11-10
301
304
" ;
302
305
303
- var versionAndBranchFinder = new ExecuteCore ( fileSystem , environment , log ) ;
306
+ var versionAndBranchFinder = new ExecuteCore ( fileSystem , environment , log , configFileLocator ) ;
304
307
305
308
RepositoryScope ( versionAndBranchFinder , ( fixture , vv ) =>
306
309
{
310
+ var arguments = new Arguments { TargetPath = fixture . RepositoryPath } ;
311
+
307
312
fileSystem . WriteAllText ( vv . FileName , versionCacheFileContent ) ;
308
- vv = versionAndBranchFinder . ExecuteGitVersion ( null , null , null , null , false , fixture . RepositoryPath , null ) ;
313
+ vv = versionAndBranchFinder . ExecuteGitVersion ( arguments ) ;
309
314
vv . AssemblySemVer . ShouldBe ( "4.10.3.0" ) ;
310
315
311
- vv = versionAndBranchFinder . ExecuteGitVersion ( null , null , null , null , false , fixture . RepositoryPath , null , noCache : true ) ;
316
+ arguments . NoCache = true ;
317
+ vv = versionAndBranchFinder . ExecuteGitVersion ( arguments ) ;
312
318
vv . AssemblySemVer . ShouldBe ( "0.1.0.0" ) ;
313
319
} ) ;
314
320
}
@@ -317,11 +323,13 @@ public void NoCacheBypassesCache()
317
323
[ Test ]
318
324
public void WorkingDirectoryWithoutGit ( )
319
325
{
320
- var versionAndBranchFinder = new ExecuteCore ( fileSystem , environment , log ) ;
326
+ var versionAndBranchFinder = new ExecuteCore ( fileSystem , environment , log , configFileLocator ) ;
321
327
322
328
RepositoryScope ( versionAndBranchFinder , ( fixture , vv ) =>
323
329
{
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 ) ) ;
325
333
exception . Message . ShouldContain ( "Can't find the .git directory in" ) ;
326
334
} ) ;
327
335
}
@@ -331,7 +339,7 @@ public void WorkingDirectoryWithoutGit()
331
339
[ Description ( "LibGit2Sharp fails when running under Mono" ) ]
332
340
public void GetProjectRootDirectory_WorkingDirectoryWithWorktree ( )
333
341
{
334
- var versionAndBranchFinder = new ExecuteCore ( fileSystem , environment , log ) ;
342
+ var versionAndBranchFinder = new ExecuteCore ( fileSystem , environment , log , configFileLocator ) ;
335
343
336
344
RepositoryScope ( versionAndBranchFinder , ( fixture , vv ) =>
337
345
{
@@ -356,7 +364,7 @@ public void GetProjectRootDirectory_WorkingDirectoryWithWorktree()
356
364
[ Test ]
357
365
public void GetProjectRootDirectory_NoWorktree ( )
358
366
{
359
- var versionAndBranchFinder = new ExecuteCore ( fileSystem , environment , log ) ;
367
+ var versionAndBranchFinder = new ExecuteCore ( fileSystem , environment , log , configFileLocator ) ;
360
368
361
369
RepositoryScope ( versionAndBranchFinder , ( fixture , vv ) =>
362
370
{
@@ -370,18 +378,25 @@ public void GetProjectRootDirectory_NoWorktree()
370
378
[ Test ]
371
379
public void DynamicRepositoriesShouldNotErrorWithFailedToFindGitDirectory ( )
372
380
{
373
- var versionAndBranchFinder = new ExecuteCore ( fileSystem , environment , log ) ;
381
+ var versionAndBranchFinder = new ExecuteCore ( fileSystem , environment , log , configFileLocator ) ;
374
382
375
383
RepositoryScope ( versionAndBranchFinder , ( fixture , vv ) =>
376
384
{
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 ) ;
378
393
} ) ;
379
394
}
380
395
381
396
[ Test ]
382
397
public void GetDotGitDirectory_NoWorktree ( )
383
398
{
384
- var versionAndBranchFinder = new ExecuteCore ( fileSystem , environment , log ) ;
399
+ var versionAndBranchFinder = new ExecuteCore ( fileSystem , environment , log , configFileLocator ) ;
385
400
386
401
RepositoryScope ( versionAndBranchFinder , ( fixture , vv ) =>
387
402
{
@@ -397,7 +412,7 @@ public void GetDotGitDirectory_NoWorktree()
397
412
[ Description ( "LibGit2Sharp fails when running under Mono" ) ]
398
413
public void GetDotGitDirectory_Worktree ( )
399
414
{
400
- var versionAndBranchFinder = new ExecuteCore ( fileSystem , environment , log ) ;
415
+ var versionAndBranchFinder = new ExecuteCore ( fileSystem , environment , log , configFileLocator ) ;
401
416
402
417
RepositoryScope ( versionAndBranchFinder , ( fixture , vv ) =>
403
418
{
@@ -428,9 +443,11 @@ private void RepositoryScope(ExecuteCore executeCore, Action<EmptyRepositoryFixt
428
443
environment . SetEnvironmentVariable ( TravisCI . EnvironmentVariableName , null ) ;
429
444
environment . SetEnvironmentVariable ( AzurePipelines . EnvironmentVariableName , null ) ;
430
445
446
+
431
447
using var fixture = new EmptyRepositoryFixture ( ) ;
448
+ var arguments = new Arguments { TargetPath = fixture . RepositoryPath } ;
432
449
fixture . Repository . MakeACommit ( ) ;
433
- var vv = executeCore . ExecuteGitVersion ( null , null , null , null , false , fixture . RepositoryPath , null ) ;
450
+ var vv = executeCore . ExecuteGitVersion ( arguments ) ;
434
451
435
452
vv . AssemblySemVer . ShouldBe ( "0.1.0.0" ) ;
436
453
vv . FileName . ShouldNotBeNullOrEmpty ( ) ;
0 commit comments