@@ -26,12 +26,7 @@ public void CacheKeySameAfterReNormalizing()
26
26
const string targetUrl = "https://github.com/GitTools/GitVersion.git" ;
27
27
const string targetBranch = $ "refs/head/{ MainBranch } ";
28
28
29
- var gitVersionOptions = new GitVersionOptions
30
- {
31
- RepositoryInfo = { TargetUrl = targetUrl , TargetBranch = targetBranch } ,
32
- WorkingDirectory = fixture . RepositoryPath ,
33
- Settings = { NoNormalize = false }
34
- } ;
29
+ var gitVersionOptions = new GitVersionOptions { RepositoryInfo = { TargetUrl = targetUrl , TargetBranch = targetBranch } , WorkingDirectory = fixture . RepositoryPath , Settings = { NoNormalize = false } } ;
35
30
36
31
var environment = new TestEnvironment ( ) ;
37
32
environment . SetEnvironmentVariable ( AzurePipelines . EnvironmentVariableName , "true" ) ;
@@ -55,11 +50,7 @@ public void GitPreparerShouldNotFailWhenTargetPathNotInitialized()
55
50
{
56
51
const string targetUrl = "https://github.com/GitTools/GitVersion.git" ;
57
52
58
- var gitVersionOptions = new GitVersionOptions
59
- {
60
- RepositoryInfo = { TargetUrl = targetUrl } ,
61
- WorkingDirectory = string . Empty
62
- } ;
53
+ var gitVersionOptions = new GitVersionOptions { RepositoryInfo = { TargetUrl = targetUrl } , WorkingDirectory = string . Empty } ;
63
54
Should . NotThrow ( ( ) =>
64
55
{
65
56
this . sp = GetServiceProvider ( gitVersionOptions ) ;
@@ -82,11 +73,7 @@ public void CacheKeyForWorktree()
82
73
83
74
const string targetUrl = "https://github.com/GitTools/GitVersion.git" ;
84
75
85
- var gitVersionOptions = new GitVersionOptions
86
- {
87
- RepositoryInfo = { TargetUrl = targetUrl , TargetBranch = MainBranch } ,
88
- WorkingDirectory = worktreePath
89
- } ;
76
+ var gitVersionOptions = new GitVersionOptions { RepositoryInfo = { TargetUrl = targetUrl , TargetBranch = MainBranch } , WorkingDirectory = worktreePath } ;
90
77
91
78
this . sp = GetServiceProvider ( gitVersionOptions ) ;
92
79
@@ -148,7 +135,11 @@ public void CacheFileExistsOnDisk()
148
135
var versionVariables = gitVersionCalculator . CalculateVersionVariables ( ) ;
149
136
versionVariables . AssemblySemVer . ShouldBe ( "0.0.1.0" ) ;
150
137
151
- this . fileSystem . WriteAllText ( versionVariables . FileName , versionCacheFileContent ) ;
138
+ var cacheKeyFactory = this . sp . GetRequiredService < IGitVersionCacheKeyFactory > ( ) ;
139
+ var cacheKey = cacheKeyFactory . Create ( null ) ;
140
+ var cacheFileName = this . gitVersionCache . GetCacheFileName ( cacheKey ) ;
141
+
142
+ this . fileSystem . WriteAllText ( cacheFileName , versionCacheFileContent ) ;
152
143
versionVariables = gitVersionCalculator . CalculateVersionVariables ( ) ;
153
144
versionVariables . AssemblySemVer . ShouldBe ( "4.10.3.0" ) ;
154
145
@@ -195,7 +186,10 @@ public void CacheFileExistsOnDiskWhenOverrideConfigIsSpecifiedVersionShouldBeDyn
195
186
var versionVariables = gitVersionCalculator . CalculateVersionVariables ( ) ;
196
187
versionVariables . AssemblySemVer . ShouldBe ( "0.0.1.0" ) ;
197
188
198
- this . fileSystem . WriteAllText ( versionVariables . FileName , versionCacheFileContent ) ;
189
+ var cacheKeyFactory = this . sp . GetRequiredService < IGitVersionCacheKeyFactory > ( ) ;
190
+ var cacheKey = cacheKeyFactory . Create ( null ) ;
191
+ var cacheFileName = this . gitVersionCache . GetCacheFileName ( cacheKey ) ;
192
+ this . fileSystem . WriteAllText ( cacheFileName , versionCacheFileContent ) ;
199
193
200
194
var cacheDirectory = this . gitVersionCache . GetCacheDirectory ( ) ;
201
195
@@ -204,11 +198,7 @@ public void CacheFileExistsOnDiskWhenOverrideConfigIsSpecifiedVersionShouldBeDyn
204
198
var configuration = GitFlowConfigurationBuilder . New . WithLabelPrefix ( "prefix" ) . Build ( ) ;
205
199
var overrideConfiguration = new ConfigurationHelper ( configuration ) . Dictionary ;
206
200
207
- gitVersionOptions = new GitVersionOptions
208
- {
209
- WorkingDirectory = fixture . RepositoryPath ,
210
- ConfigurationInfo = { OverrideConfiguration = overrideConfiguration }
211
- } ;
201
+ gitVersionOptions = new GitVersionOptions { WorkingDirectory = fixture . RepositoryPath , ConfigurationInfo = { OverrideConfiguration = overrideConfiguration } } ;
212
202
213
203
gitVersionCalculator = GetGitVersionCalculator ( gitVersionOptions ) ;
214
204
versionVariables = gitVersionCalculator . CalculateVersionVariables ( ) ;
@@ -283,9 +273,12 @@ public void ConfigChangeInvalidatesCache(string configFileName)
283
273
var versionVariables = gitVersionCalculator . CalculateVersionVariables ( ) ;
284
274
285
275
versionVariables . AssemblySemVer . ShouldBe ( "0.0.1.0" ) ;
286
- versionVariables . FileName . ShouldNotBeNullOrEmpty ( ) ;
287
276
288
- this . fileSystem . WriteAllText ( versionVariables . FileName , versionCacheFileContent ) ;
277
+ var cacheKeyFactory = this . sp . GetRequiredService < IGitVersionCacheKeyFactory > ( ) ;
278
+ var cacheKey = cacheKeyFactory . Create ( null ) ;
279
+ var cacheFileName = this . gitVersionCache . GetCacheFileName ( cacheKey ) ;
280
+
281
+ this . fileSystem . WriteAllText ( cacheFileName , versionCacheFileContent ) ;
289
282
290
283
versionVariables = gitVersionCalculator . CalculateVersionVariables ( ) ;
291
284
versionVariables . AssemblySemVer . ShouldBe ( "4.10.3.0" ) ;
@@ -340,9 +333,12 @@ public void NoCacheBypassesCache()
340
333
var versionVariables = gitVersionCalculator . CalculateVersionVariables ( ) ;
341
334
342
335
versionVariables . AssemblySemVer . ShouldBe ( "0.0.1.0" ) ;
343
- versionVariables . FileName . ShouldNotBeNullOrEmpty ( ) ;
344
336
345
- this . fileSystem . WriteAllText ( versionVariables . FileName , versionCacheFileContent ) ;
337
+ var cacheKeyFactory = this . sp . GetRequiredService < IGitVersionCacheKeyFactory > ( ) ;
338
+ var cacheKey = cacheKeyFactory . Create ( null ) ;
339
+ var cacheFileName = this . gitVersionCache . GetCacheFileName ( cacheKey ) ;
340
+
341
+ this . fileSystem . WriteAllText ( cacheFileName , versionCacheFileContent ) ;
346
342
versionVariables = gitVersionCalculator . CalculateVersionVariables ( ) ;
347
343
versionVariables . AssemblySemVer . ShouldBe ( "4.10.3.0" ) ;
348
344
@@ -394,11 +390,7 @@ public void GetProjectRootDirectoryWorkingDirectoryWithWorktree()
394
390
395
391
const string targetUrl = "https://github.com/GitTools/GitVersion.git" ;
396
392
397
- var gitVersionOptions = new GitVersionOptions
398
- {
399
- RepositoryInfo = { TargetUrl = targetUrl } ,
400
- WorkingDirectory = worktreePath
401
- } ;
393
+ var gitVersionOptions = new GitVersionOptions { RepositoryInfo = { TargetUrl = targetUrl } , WorkingDirectory = worktreePath } ;
402
394
403
395
this . sp = GetServiceProvider ( gitVersionOptions ) ;
404
396
var repositoryInfo = this . sp . GetRequiredService < IGitRepositoryInfo > ( ) ;
@@ -416,11 +408,7 @@ public void GetProjectRootDirectoryNoWorktree()
416
408
using var fixture = new EmptyRepositoryFixture ( ) ;
417
409
const string targetUrl = "https://github.com/GitTools/GitVersion.git" ;
418
410
419
- var gitVersionOptions = new GitVersionOptions
420
- {
421
- RepositoryInfo = { TargetUrl = targetUrl } ,
422
- WorkingDirectory = fixture . RepositoryPath
423
- } ;
411
+ var gitVersionOptions = new GitVersionOptions { RepositoryInfo = { TargetUrl = targetUrl } , WorkingDirectory = fixture . RepositoryPath } ;
424
412
425
413
this . sp = GetServiceProvider ( gitVersionOptions ) ;
426
414
var repositoryInfo = this . sp . GetRequiredService < IGitRepositoryInfo > ( ) ;
@@ -434,10 +422,7 @@ public void GetDotGitDirectoryNoWorktree()
434
422
{
435
423
using var fixture = new EmptyRepositoryFixture ( ) ;
436
424
437
- var gitVersionOptions = new GitVersionOptions
438
- {
439
- WorkingDirectory = fixture . RepositoryPath
440
- } ;
425
+ var gitVersionOptions = new GitVersionOptions { WorkingDirectory = fixture . RepositoryPath } ;
441
426
442
427
this . sp = GetServiceProvider ( gitVersionOptions ) ;
443
428
var repositoryInfo = this . sp . GetRequiredService < IGitRepositoryInfo > ( ) ;
@@ -459,10 +444,7 @@ public void GetDotGitDirectoryWorktree()
459
444
var repo = new Repository ( fixture . RepositoryPath ) ;
460
445
repo . Worktrees . Add ( "worktree" , worktreePath , false ) ;
461
446
462
- var gitVersionOptions = new GitVersionOptions
463
- {
464
- WorkingDirectory = worktreePath
465
- } ;
447
+ var gitVersionOptions = new GitVersionOptions { WorkingDirectory = worktreePath } ;
466
448
467
449
this . sp = GetServiceProvider ( gitVersionOptions ) ;
468
450
var repositoryInfo = this . sp . GetRequiredService < IGitRepositoryInfo > ( ) ;
0 commit comments