@@ -26,12 +26,7 @@ public void CacheKeySameAfterReNormalizing()
2626 const string targetUrl = "https://github.com/GitTools/GitVersion.git" ;
2727 const string targetBranch = $ "refs/head/{ MainBranch } ";
2828
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 } } ;
3530
3631 var environment = new TestEnvironment ( ) ;
3732 environment . SetEnvironmentVariable ( AzurePipelines . EnvironmentVariableName , "true" ) ;
@@ -55,11 +50,7 @@ public void GitPreparerShouldNotFailWhenTargetPathNotInitialized()
5550 {
5651 const string targetUrl = "https://github.com/GitTools/GitVersion.git" ;
5752
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 } ;
6354 Should . NotThrow ( ( ) =>
6455 {
6556 this . sp = GetServiceProvider ( gitVersionOptions ) ;
@@ -82,11 +73,7 @@ public void CacheKeyForWorktree()
8273
8374 const string targetUrl = "https://github.com/GitTools/GitVersion.git" ;
8475
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 } ;
9077
9178 this . sp = GetServiceProvider ( gitVersionOptions ) ;
9279
@@ -148,7 +135,11 @@ public void CacheFileExistsOnDisk()
148135 var versionVariables = gitVersionCalculator . CalculateVersionVariables ( ) ;
149136 versionVariables . AssemblySemVer . ShouldBe ( "0.0.1.0" ) ;
150137
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 ) ;
152143 versionVariables = gitVersionCalculator . CalculateVersionVariables ( ) ;
153144 versionVariables . AssemblySemVer . ShouldBe ( "4.10.3.0" ) ;
154145
@@ -195,7 +186,10 @@ public void CacheFileExistsOnDiskWhenOverrideConfigIsSpecifiedVersionShouldBeDyn
195186 var versionVariables = gitVersionCalculator . CalculateVersionVariables ( ) ;
196187 versionVariables . AssemblySemVer . ShouldBe ( "0.0.1.0" ) ;
197188
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 ) ;
199193
200194 var cacheDirectory = this . gitVersionCache . GetCacheDirectory ( ) ;
201195
@@ -204,11 +198,7 @@ public void CacheFileExistsOnDiskWhenOverrideConfigIsSpecifiedVersionShouldBeDyn
204198 var configuration = GitFlowConfigurationBuilder . New . WithLabelPrefix ( "prefix" ) . Build ( ) ;
205199 var overrideConfiguration = new ConfigurationHelper ( configuration ) . Dictionary ;
206200
207- gitVersionOptions = new GitVersionOptions
208- {
209- WorkingDirectory = fixture . RepositoryPath ,
210- ConfigurationInfo = { OverrideConfiguration = overrideConfiguration }
211- } ;
201+ gitVersionOptions = new GitVersionOptions { WorkingDirectory = fixture . RepositoryPath , ConfigurationInfo = { OverrideConfiguration = overrideConfiguration } } ;
212202
213203 gitVersionCalculator = GetGitVersionCalculator ( gitVersionOptions ) ;
214204 versionVariables = gitVersionCalculator . CalculateVersionVariables ( ) ;
@@ -283,9 +273,12 @@ public void ConfigChangeInvalidatesCache(string configFileName)
283273 var versionVariables = gitVersionCalculator . CalculateVersionVariables ( ) ;
284274
285275 versionVariables . AssemblySemVer . ShouldBe ( "0.0.1.0" ) ;
286- versionVariables . FileName . ShouldNotBeNullOrEmpty ( ) ;
287276
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 ) ;
289282
290283 versionVariables = gitVersionCalculator . CalculateVersionVariables ( ) ;
291284 versionVariables . AssemblySemVer . ShouldBe ( "4.10.3.0" ) ;
@@ -340,9 +333,12 @@ public void NoCacheBypassesCache()
340333 var versionVariables = gitVersionCalculator . CalculateVersionVariables ( ) ;
341334
342335 versionVariables . AssemblySemVer . ShouldBe ( "0.0.1.0" ) ;
343- versionVariables . FileName . ShouldNotBeNullOrEmpty ( ) ;
344336
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 ) ;
346342 versionVariables = gitVersionCalculator . CalculateVersionVariables ( ) ;
347343 versionVariables . AssemblySemVer . ShouldBe ( "4.10.3.0" ) ;
348344
@@ -394,11 +390,7 @@ public void GetProjectRootDirectoryWorkingDirectoryWithWorktree()
394390
395391 const string targetUrl = "https://github.com/GitTools/GitVersion.git" ;
396392
397- var gitVersionOptions = new GitVersionOptions
398- {
399- RepositoryInfo = { TargetUrl = targetUrl } ,
400- WorkingDirectory = worktreePath
401- } ;
393+ var gitVersionOptions = new GitVersionOptions { RepositoryInfo = { TargetUrl = targetUrl } , WorkingDirectory = worktreePath } ;
402394
403395 this . sp = GetServiceProvider ( gitVersionOptions ) ;
404396 var repositoryInfo = this . sp . GetRequiredService < IGitRepositoryInfo > ( ) ;
@@ -416,11 +408,7 @@ public void GetProjectRootDirectoryNoWorktree()
416408 using var fixture = new EmptyRepositoryFixture ( ) ;
417409 const string targetUrl = "https://github.com/GitTools/GitVersion.git" ;
418410
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 } ;
424412
425413 this . sp = GetServiceProvider ( gitVersionOptions ) ;
426414 var repositoryInfo = this . sp . GetRequiredService < IGitRepositoryInfo > ( ) ;
@@ -434,10 +422,7 @@ public void GetDotGitDirectoryNoWorktree()
434422 {
435423 using var fixture = new EmptyRepositoryFixture ( ) ;
436424
437- var gitVersionOptions = new GitVersionOptions
438- {
439- WorkingDirectory = fixture . RepositoryPath
440- } ;
425+ var gitVersionOptions = new GitVersionOptions { WorkingDirectory = fixture . RepositoryPath } ;
441426
442427 this . sp = GetServiceProvider ( gitVersionOptions ) ;
443428 var repositoryInfo = this . sp . GetRequiredService < IGitRepositoryInfo > ( ) ;
@@ -459,10 +444,7 @@ public void GetDotGitDirectoryWorktree()
459444 var repo = new Repository ( fixture . RepositoryPath ) ;
460445 repo . Worktrees . Add ( "worktree" , worktreePath , false ) ;
461446
462- var gitVersionOptions = new GitVersionOptions
463- {
464- WorkingDirectory = worktreePath
465- } ;
447+ var gitVersionOptions = new GitVersionOptions { WorkingDirectory = worktreePath } ;
466448
467449 this . sp = GetServiceProvider ( gitVersionOptions ) ;
468450 var repositoryInfo = this . sp . GetRequiredService < IGitRepositoryInfo > ( ) ;
0 commit comments