Conversation
…licated error handling The three gh API fetch functions (fetchPRHeadSHA, fetchCheckRuns, fetchCommitStatuses) all shared identical patterns for building args, calling workflow.ExecGH, handling exec.ExitError, and classifying API errors. Extract a single execGHAPI helper that centralises this logic. Each caller is now reduced to: build the URL, call execGHAPI, parse the JSON response — making the intent of each function immediately clear. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
pelikhan
approved these changes
Feb 24, 2026
Contributor
|
/q update code simplifier with network go domain. |
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Code Simplification - 2026-02-24
This PR simplifies recently modified code from PR #18164 to improve clarity and reduce duplication while preserving all functionality.
Files Simplified
pkg/cli/checks_command.go— extractedexecGHAPIhelper to eliminate triplicated gh API call + error handling codeImprovements Made
Eliminated duplicated error handling pattern
fetchPRHeadSHA,fetchCheckRuns, andfetchCommitStatusesall contained identical boilerplate for:--repoflag when setworkflow.ExecGH(...)*exec.ExitErrorto extract stderrclassifyGHAPIErrorThe new
execGHAPI(repoOverride, context, args...)helper centralises this pattern. Each caller now simply:execGHAPIwith its endpoint URLThis makes the intent of each fetch function immediately clear and eliminates ~18 lines of duplicated error-handling code.
Changes Based On
Recent code from:
gh aw checkscommand for deterministic PR CI state classification #18164 — Addgh aw checkscommand for deterministic PR CI stateTesting
gofmtpasses — no formatting changes neededclassifyGHAPIError)pkg/cli/checks_command_test.govalidates behaviorReview Focus
Please verify:
execGHAPIcorrectly handles the--repoappend and error classificationfetchPRHeadSHA,fetchCheckRuns,fetchCommitStatuses) behave identically to beforeargsappend patternAutomated by Code Simplifier Agent — analyzing code from the last 24 hours
Warning
The following domain was blocked by the firewall during workflow execution:
proxy.golang.org