Skip to content

Commit 7bee35a

Browse files
CopilotMalcolmnixon
andcommitted
Fix code review issues: add refs/heads prefix and null checks
Co-authored-by: Malcolmnixon <1863707+Malcolmnixon@users.noreply.github.com>
1 parent 7e29755 commit 7bee35a

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/DemaConsulting.BuildMark/RepoConnectors/GitHub/GitHubGraphQLClient.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ internal GitHubGraphQLClient(HttpClient httpClient, string? graphqlEndpoint = nu
9393
/// </summary>
9494
/// <param name="owner">Repository owner.</param>
9595
/// <param name="repo">Repository name.</param>
96-
/// <param name="branch">Branch name.</param>
96+
/// <param name="branch">Branch name (e.g., 'main'). Will be automatically converted to fully qualified ref name.</param>
9797
/// <returns>List of commit SHAs on the branch.</returns>
9898
public async Task<List<string>> GetCommitsAsync(
9999
string owner,
@@ -106,6 +106,9 @@ public async Task<List<string>> GetCommitsAsync(
106106
string? afterCursor = null;
107107
bool hasNextPage;
108108

109+
// Convert branch name to fully qualified ref name if needed
110+
var qualifiedBranch = branch.StartsWith("refs/") ? branch : $"refs/heads/{branch}";
111+
109112
// Paginate through all commits on the branch
110113
do
111114
{
@@ -136,7 +139,7 @@ ... on Commit {
136139
{
137140
owner,
138141
repo,
139-
branch,
142+
branch = qualifiedBranch,
140143
after = afterCursor
141144
}
142145
};

test/DemaConsulting.BuildMark.Tests/RepoConnectors/GitHub/GitHubGraphQLClientTests.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,9 @@ protected override async Task<HttpResponseMessage> SendAsync(
350350
CancellationToken cancellationToken)
351351
{
352352
// Read request body to determine which page to return
353-
var requestBody = await request.Content!.ReadAsStringAsync(cancellationToken);
353+
var requestBody = request.Content != null
354+
? await request.Content.ReadAsStringAsync(cancellationToken)
355+
: string.Empty;
354356

355357
string responseContent;
356358
if (_requestCount == 0 || !requestBody.Contains("\"after\""))
@@ -699,7 +701,9 @@ protected override async Task<HttpResponseMessage> SendAsync(
699701
CancellationToken cancellationToken)
700702
{
701703
// Read request body to determine which page to return
702-
var requestBody = await request.Content!.ReadAsStringAsync(cancellationToken);
704+
var requestBody = request.Content != null
705+
? await request.Content.ReadAsStringAsync(cancellationToken)
706+
: string.Empty;
703707

704708
string responseContent;
705709
if (_requestCount == 0 || !requestBody.Contains("\"after\""))

0 commit comments

Comments
 (0)