Skip to content

Conversation

adamzip
Copy link
Contributor

@adamzip adamzip commented May 20, 2025

@adamzip adamzip marked this pull request as ready for review May 20, 2025 14:51
@Copilot Copilot AI review requested due to automatic review settings May 20, 2025 14:51
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request implements etag-based caching for GitHub API resource requests while updating various usages of pull request properties across the codebase. Key changes include updating pull request types to use Octokit types, adding caching via StackExchange.Redis in GitHubClient, and adjusting properties from TargetBranchCommitSha to HeadCommitSha where appropriate.

Reviewed Changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
test/ProductConstructionService.ScenarioTests/CodeFlowScenarioTestBase.cs Uses Octokit.PullRequest instead of the ambiguous PullRequest type in tests.
test/Microsoft.DotNet.DarcLib.Tests/GitHubClientTests.cs Updates constructor parameters to accommodate additional Redis caching support.
src/Microsoft.DotNet.Darc/DarcLib/GitHubClient.cs Implements etag-based caching and updates pull request and review fetching logic.
src/Microsoft.DotNet.Darc/DarcLib/Models/IRemoteGitResource.cs Introduces a new resource model with an etag property.
src/Maestro/Maestro.DataProviders/RemoteFactory.cs Adds a direct connection to Redis, with a note to replace it with DI.
Comments suppressed due to low confidence (1)

src/Microsoft.DotNet.Darc/DarcLib/Models/IRemoteGitResource.cs:5

  • The name 'IRemoteGitResource' suggests an interface, but it is declared as a class. Consider renaming it to 'RemoteGitResource' or converting it to an interface for clarity.
public class IRemoteGitResource

Comment on lines +956 to +966
GitPullRequestReviews reviews = await RequestResourceUsingEtagsAsync<GitPullRequestReviews, ICollection<PullRequestReview>>(
pullRequestUrl,
"endpoint",
Copy link
Preview

Copilot AI May 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The endpoint argument is hardcoded as 'endpoint' in the RequestResourceUsingEtagsAsync call for pull request reviews. Consider constructing the correct endpoint URL to ensure the right API resource is fetched.

Suggested change
GitPullRequestReviews reviews = await RequestResourceUsingEtagsAsync<GitPullRequestReviews, ICollection<PullRequestReview>>(
pullRequestUrl,
"endpoint",
string reviewsEndpoint = $"/repos/{owner}/{repo}/pulls/{id}/reviews";
GitPullRequestReviews reviews = await RequestResourceUsingEtagsAsync<GitPullRequestReviews, ICollection<PullRequestReview>>(
pullRequestUrl,
reviewsEndpoint,

Copilot uses AI. Check for mistakes.

@@ -44,6 +47,7 @@ public RemoteFactory(
_azdoTokenProvider = azdoTokenProvider;
_cache = memoryCache;
_serviceProvider = serviceProvider;
_connection = ConnectionMultiplexer.Connect(options); //todo replace this with DI injection of IConnectionMultiplexer. We shouldn't do this in non-singleton classes, or even in general
Copy link
Preview

Copilot AI May 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instantiating ConnectionMultiplexer directly in the constructor can lead to connection lifecycle issues. Consider using dependency injection to manage the connection instance.

Copilot uses AI. Check for mistakes.

IGitHubClient client = GetClient(owner, repo);
GitPullRequestReviews reviews = await RequestResourceUsingEtagsAsync<GitPullRequestReviews, ICollection<PullRequestReview>>(
pullRequestUrl,
"endpoint",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: replace this placeholder

// The .NET Foundation licenses this file to you under the MIT license.

namespace Microsoft.DotNet.DarcLib.Models;
public class IRemoteGitResource
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename class or turn into an interface

@adamzip adamzip changed the title Use etags to request resources from GitHub API Use etags in Github requests Jun 2, 2025
@adamzip adamzip force-pushed the use-github-etags branch 3 times, most recently from 63b8d98 to d75009f Compare July 20, 2025 16:22
@adamzip adamzip force-pushed the use-github-etags branch from d75009f to dbe7b72 Compare July 20, 2025 21:32
@adamzip adamzip closed this Jul 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant