Skip to content

Commit 3aea320

Browse files
committed
resolveGitReference - NewGitHubAPIErrorToCtx
1 parent 43d72ed commit 3aea320

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

pkg/github/repositories.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1344,17 +1344,19 @@ func resolveGitReference(ctx context.Context, githubClient *github.Client, owner
13441344

13451345
// 2. If neither provided, use the default branch as ref
13461346
if ref == "" {
1347-
repoInfo, _, err := githubClient.Repositories.Get(ctx, owner, repo)
1347+
repoInfo, resp, err := githubClient.Repositories.Get(ctx, owner, repo)
13481348
if err != nil {
1349+
_, _ = ghErrors.NewGitHubAPIErrorToCtx(ctx, "failed to get repository info", resp, err)
13491350
return nil, fmt.Errorf("failed to get repository info: %w", err)
13501351
}
13511352
ref = fmt.Sprintf("refs/heads/%s", repoInfo.GetDefaultBranch())
13521353
}
13531354

13541355
// 3. Get the SHA from the ref
1355-
reference, _, err := githubClient.Git.GetRef(ctx, owner, repo, ref)
1356+
reference, resp, err := githubClient.Git.GetRef(ctx, owner, repo, ref)
13561357
if err != nil {
1357-
return nil, fmt.Errorf("failed to get reference for default branch: %w", err)
1358+
_, _ = ghErrors.NewGitHubAPIErrorToCtx(ctx, "failed to get reference", resp, err)
1359+
return nil, fmt.Errorf("failed to get reference: %w", err)
13581360
}
13591361
sha = reference.GetObject().GetSHA()
13601362

0 commit comments

Comments
 (0)