Skip to content

Commit f828c84

Browse files
committed
improves branch/tag cache keys
Simplifies branch/tag cache keys by including the remote name and SHA.
1 parent 719cc5f commit f828c84

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/GitVersion.LibGit2Sharp/Git/GitRepository.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,17 +70,17 @@ public Branch GetOrCreate(LibGit2Sharp.Branch innerBranch, Diff repoDiff)
7070
return new Branch(innerBranch, repoDiff, this);
7171
}
7272

73-
var cacheKey = $"{innerBranch.CanonicalName}|{innerBranch.Tip.Sha}|{innerBranch.RemoteName}";
74-
return cachedBranches.GetOrAdd(cacheKey, new Branch(innerBranch, repoDiff, this));
73+
var cacheKey = $"{innerBranch.RemoteName}/{innerBranch.CanonicalName}@{innerBranch.Tip.Sha}";
74+
return cachedBranches.GetOrAdd(cacheKey, _ => new Branch(innerBranch, repoDiff, this));
7575
}
7676

7777
public Commit GetOrCreate(LibGit2Sharp.Commit innerCommit, Diff repoDiff) =>
78-
cachedCommits.GetOrAdd(innerCommit.Sha, new Commit(innerCommit, repoDiff, this));
78+
cachedCommits.GetOrAdd(innerCommit.Sha, _ => new Commit(innerCommit, repoDiff, this));
7979

8080
public Tag GetOrCreate(LibGit2Sharp.Tag innerTag, Diff repoDiff)
8181
{
82-
var cacheKey = $"{innerTag.CanonicalName}|{innerTag.Target.Sha}";
83-
return cachedTags.GetOrAdd(cacheKey, new Tag(innerTag, repoDiff, this));
82+
var cacheKey = $"{innerTag.CanonicalName}@{innerTag.Target.Sha}";
83+
return cachedTags.GetOrAdd(cacheKey, _ => new Tag(innerTag, repoDiff, this));
8484
}
8585

8686
public void Dispose()

0 commit comments

Comments
 (0)