Skip to content

Commit 5a4b29b

Browse files
asbjornuJakeGinnivan
authored andcommitted
Make the VersionAndBranchFinder.VersionCacheVersions dictionary internal and internals visible to GitVersionTask.Tests so we can reset the in-memory cache for testing. Not very elegant, but that's static for you. :-/
1 parent ea02513 commit 5a4b29b

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/GitVersionTask/AssemblyInfo.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
using System.Reflection;
2+
using System.Runtime.CompilerServices;
23

34
[assembly: AssemblyTitle("GitVersionTask")]
45
[assembly: AssemblyProduct("GitVersionTask")]
56
[assembly: AssemblyVersion("1.0.0")]
67
[assembly: AssemblyFileVersion("1.0.0")]
8+
[assembly: InternalsVisibleTo("GitVersionTask.Tests")]

src/GitVersionTask/VersionAndBranchFinder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
public static class VersionAndBranchFinder
1515
{
16-
static ConcurrentDictionary<string, VersionVariables> versionCacheVersions = new ConcurrentDictionary<string, VersionVariables>();
16+
internal static ConcurrentDictionary<string, VersionVariables> VersionCacheVersions = new ConcurrentDictionary<string, VersionVariables>();
1717

1818

1919
public static bool TryGetVersion(string directory, out VersionVariables versionVariables, bool noFetch, Authentication authentication, IFileSystem fileSystem)
@@ -41,7 +41,7 @@ public static VersionVariables GetVersion(string directory, Authentication authe
4141
var ticks = fileSystem.GetLastDirectoryWrite(Path.Combine(gitDir, "refs"));
4242
string key = string.Format("{0}:{1}:{2}:{3}", gitDir, repo.Head.CanonicalName, repo.Head.Tip.Sha, ticks);
4343

44-
return versionCacheVersions.GetOrAdd(key, k =>
44+
return VersionCacheVersions.GetOrAdd(key, k =>
4545
{
4646
Logger.WriteInfo("Version not in memory cache. Attempting to load version from disk cache.");
4747
return LoadVersionVariablesFromDiskCache(k, directory, authentication, noFetch, fileSystem, gitDir, ticks);

0 commit comments

Comments
 (0)