Skip to content

Commit 16fa965

Browse files
dkurepaCopilot
andauthored
Fix eng/common cashing (#4829)
<!-- Link the GitHub or AzDO issue this pull request is associated with. Please copy and paste the full URL rather than using the dotnet/arcade-services# syntax --> #4751 --------- Co-authored-by: Copilot <[email protected]>
1 parent 080ee12 commit 16fa965

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/Microsoft.DotNet.Darc/DarcLib/GitHubClient.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,10 @@ public async Task<List<GitFile>> GetFilesAtCommitAsync(string repoUri, string co
660660

661661
if (Cache != null)
662662
{
663-
return await Cache.GetOrCreateAsync((treeItem.Path, treeItem.Sha), async (entry) =>
663+
// We're adding the full path here because the eng/common files have the same relative path in the VMR
664+
// and in product repos relative to the eng/common folder, and we don't want to get bad cache hits.
665+
// Their full paths are different so this mitigates the problem
666+
return await Cache.GetOrCreateAsync((path, treeItem.Path, treeItem.Sha), async (entry) =>
664667
{
665668
GitFile file = await GetGitItemImpl(path, treeItem, owner, repo);
666669

test/Microsoft.DotNet.DarcLib.Tests/GitHubClientTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ public async Task TreeItemCacheTest(bool enableCache)
289289
cache.CacheHits.Should().Be(expectedCacheHits);
290290
// Get it again, this time it should be in the cache
291291
expectedCacheHits++;
292-
await client.Object.GetGitTreeItem("anotherPath", treeItemsToGet[0].Item3, treeItemsToGet[0].Item1, treeItemsToGet[0].Item2);
292+
await client.Object.GetGitTreeItem("anotherPath", renamedTreeItem.Item3, renamedTreeItem.Item1, renamedTreeItem.Item2);
293293
cache.CacheHits.Should().Be(expectedCacheHits);
294294
}
295295
}

0 commit comments

Comments
 (0)