-
Notifications
You must be signed in to change notification settings - Fork 78
Use GraphQL to collect eng/common
from GitHub
#4828
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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 PR migrates GitHub file retrieval to use GraphQL, reducing rate limiting issues and improving performance. Key changes include:
- Removing legacy caching and abuse retry tests.
- Removing memory cache support from RemoteRepoBase and adjusting dependent constructors.
- Updating GitHubClient to perform file retrieval via GraphQL with added logging and caching.
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
test/Microsoft.DotNet.DarcLib.Tests/GitHubClientTests.cs | Removed tests for caching and abuse exception retry scenarios |
src/Microsoft.DotNet.Darc/DarcLib/RemoteRepoBase.cs | Removed memory cache parameter and property to simplify repository access |
src/Microsoft.DotNet.Darc/DarcLib/LocalLibGit2Client.cs | Added error handling around file mode conversion with improved logging |
src/Microsoft.DotNet.Darc/DarcLib/Helpers/GitFile.cs | Updated newline logic for content normalization |
src/Microsoft.DotNet.Darc/DarcLib/GitHubClient.cs | Implemented GraphQL query execution with caching and improved error handling |
src/Microsoft.DotNet.Darc/DarcLib/AzureDevOpsClient.cs | Adjusted base constructor call to reflect changes in caching support |
Comments suppressed due to low confidence (1)
test/Microsoft.DotNet.DarcLib.Tests/GitHubClientTests.cs:191
- The removal of caching and abuse exception tests reduces test coverage for key scenarios. Please ensure that the new GraphQL integration is adequately tested.
[TestCase(true)]
} | ||
catch | ||
{ | ||
_logger.LogError("Failed to parse file mode {mode} for file {ilePath}", file.Mode, file.FilePath); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The log message placeholder '{ilePath}' appears to be a typo. Consider updating it to '{filePath}' for clarity.
_logger.LogError("Failed to parse file mode {mode} for file {ilePath}", file.Mode, file.FilePath); | |
_logger.LogError("Failed to parse file mode {mode} for file {filePath}", file.Mode, file.FilePath); |
Copilot uses AI. Check for mistakes.
using var client = new HttpClient(); | ||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); | ||
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); | ||
client.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue("DarcLib", DarcLibVersion)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Creating a new HttpClient instance for every GraphQL query may lead to socket exhaustion. Consider using IHttpClientFactory or reusing a shared HttpClient instance.
using var client = new HttpClient(); | |
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); | |
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); | |
client.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue("DarcLib", DarcLibVersion)); | |
_httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); | |
_httpClient.DefaultRequestHeaders.UserAgent.Clear(); | |
_httpClient.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue("DarcLib", DarcLibVersion)); |
Copilot uses AI. Check for mistakes.
#4751