refactor(go-gh): migrate to typed clients, remove gh subprocess deps, centralize REST client creation#33754
Closed
Copilot wants to merge 3 commits into
Closed
refactor(go-gh): migrate to typed clients, remove gh subprocess deps, centralize REST client creation#33754Copilot wants to merge 3 commits into
Copilot wants to merge 3 commits into
Conversation
4 tasks
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
…T client creation
- Replace api.NewRESTClient(api.ClientOptions{}) with api.DefaultRESTClient()
in update_check.go and update_cooldown.go for consistency
- Replace gh.Exec graphql subprocess in repository_features_validation.go
with api.DefaultGraphQLClient() typed client; drop encoding/json and gh imports
- Replace gh.Exec SHA-resolution subprocess in remote_fetch.go with REST
client.Get call; drop root go-gh import
- Extract newRESTClientForHost(host) helper in remote_fetch.go to remove
three copies of the if-host-empty pattern
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Review Go module cli/go-gh for updates and compliance
refactor(go-gh): migrate to typed clients, remove gh subprocess deps, centralize REST client creation
May 21, 2026
Collaborator
|
@copilot merge main and recompile, fix conflicts |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors GitHub API usage to rely on go-gh typed REST/GraphQL clients instead of spawning gh subprocesses, and aligns REST client creation patterns across the codebase.
Changes:
- Replace
gh api graphqlsubprocess usage withapi.DefaultGraphQLClient()+client.Do(...)and direct typed decoding. - Replace
gh api ... --jq .shasubprocess usage with typed RESTclient.Get(...)for commit SHA resolution (with existing git fallback preserved). - Centralize host-aware REST client creation via a helper and apply
api.DefaultRESTClient()for consistency.
Show a summary per file
| File | Description |
|---|---|
| pkg/workflow/repository_features_validation.go | Switch discussions check from gh subprocess GraphQL to typed go-gh GraphQL client. |
| pkg/parser/remote_fetch.go | Replace SHA resolution subprocess with typed REST call and centralize host-aware REST client creation. |
| pkg/cli/update_cooldown.go | Use api.DefaultRESTClient() to match prevailing REST client construction style. |
| pkg/cli/update_check.go | Use api.DefaultRESTClient() to match prevailing REST client construction style. |
| .github/workflows/workflow-health-manager.lock.yml | Update embedded awf-config JSON (model aliases/allowlist config). |
| .github/workflows/workflow-generator.lock.yml | Update embedded awf-config JSON (model aliases/allowlist config). |
| .github/workflows/video-analyzer.lock.yml | Update embedded awf-config JSON (model aliases/allowlist config). |
| .github/workflows/test-workflow.lock.yml | Update embedded awf-config JSON (model aliases/allowlist config). |
| .github/workflows/test-quality-sentinel.lock.yml | Update embedded awf-config JSON (model aliases/allowlist config). |
| .github/workflows/test-project-url-default.lock.yml | Update embedded awf-config JSON (model aliases/allowlist config). |
| .github/workflows/test-dispatcher.lock.yml | Update embedded awf-config JSON (model aliases/allowlist config). |
| .github/workflows/super-linter.lock.yml | Update embedded awf-config JSON (model aliases/allowlist config). |
| .github/workflows/slide-deck-maintainer.lock.yml | Update embedded awf-config JSON (model aliases/allowlist config). |
| .github/workflows/security-review.lock.yml | Update embedded awf-config JSON (model aliases/allowlist config). |
| .github/workflows/security-compliance.lock.yml | Update embedded awf-config JSON (model aliases/allowlist config). |
| .github/workflows/repo-tree-map.lock.yml | Update embedded awf-config JSON (model aliases/allowlist config). |
| .github/workflows/refiner.lock.yml | Update embedded awf-config JSON (model aliases/allowlist config). |
| .github/workflows/q.lock.yml | Update embedded awf-config JSON (model aliases/allowlist config). |
| .github/workflows/pr-description-caveman.lock.yml | Update embedded awf-config JSON (model aliases/allowlist config). |
| .github/workflows/poem-bot.lock.yml | Update embedded awf-config JSON (model aliases/allowlist config). |
| .github/workflows/plan.lock.yml | Update embedded awf-config JSON (model aliases/allowlist config). |
| .github/workflows/pdf-summary.lock.yml | Update embedded awf-config JSON (model aliases/allowlist config). |
| .github/workflows/metrics-collector.lock.yml | Update embedded awf-config JSON (model aliases/allowlist config). |
| .github/workflows/mergefest.lock.yml | Update embedded awf-config JSON (model aliases/allowlist config). |
| .github/workflows/lint-monster.lock.yml | Update embedded awf-config JSON (model aliases/allowlist config). |
| .github/workflows/jsweep.lock.yml | Update embedded awf-config JSON (model aliases/allowlist config). |
| .github/workflows/gpclean.lock.yml | Update embedded awf-config JSON (model aliases/allowlist config). |
| .github/workflows/example-permissions-warning.lock.yml | Update embedded awf-config JSON (model aliases/allowlist config). |
| .github/workflows/dev.lock.yml | Update embedded awf-config JSON (model aliases/allowlist config). |
| .github/workflows/dev-hawk.lock.yml | Update embedded awf-config JSON (model aliases/allowlist config). |
| .github/workflows/daily-team-status.lock.yml | Update embedded awf-config JSON (model aliases/allowlist config). |
| .github/workflows/craft.lock.yml | Update embedded awf-config JSON (model aliases/allowlist config). |
| .github/workflows/contribution-check.lock.yml | Update embedded awf-config JSON (model aliases/allowlist config). |
| .github/workflows/code-simplifier.lock.yml | Update embedded awf-config JSON (model aliases/allowlist config). |
| .github/workflows/brave.lock.yml | Update embedded awf-config JSON (model aliases/allowlist config). |
| .github/workflows/archie.lock.yml | Update embedded awf-config JSON (model aliases/allowlist config). |
| .github/workflows/ace-editor.lock.yml | Update embedded awf-config JSON (model aliases/allowlist config). |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 123/237 changed files
- Comments generated: 1
Comment on lines
+452
to
+456
| var commit struct { | ||
| SHA string `json:"sha"` | ||
| } | ||
| if err := client.Get(fmt.Sprintf("repos/%s/%s/commits/%s", owner, repo, ref), &commit); err != nil { | ||
| if gitutil.IsAuthError(err.Error()) { |
Copilot stopped work on behalf of
pelikhan due to an error
May 21, 2026 14:52
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.
Go Module Review (#go-fan) identified style drift and two callsites still spawning
ghsubprocesses where typed API clients are available. This PR addresses all quick-win and best-practice items from that report.Changes
Cosmetic consistency (
update_check.go,update_cooldown.go)api.NewRESTClient(api.ClientOptions{})→api.DefaultRESTClient()to match the rest of the codebaseReplace GraphQL subprocess (
repository_features_validation.go)gh.Exec("api", "graphql", ...)→api.DefaultGraphQLClient()+client.Do(...)map[string]interface{}instead of CLI flags; response decoded directly into a typed structencoding/jsonand the rootgo-ghimport; no longer requiresghonPATHfor this flowReplace SHA-resolution subprocess (
remote_fetch.go)gh.Exec("api", apiPath, "--jq", ".sha")→ typed RESTclient.Get("repos/{owner}/{repo}/commits/{ref}", &commit)--jq .sha+strings.TrimSpacewrangling; auth-error fallback togit ls-remoteis preservedgo-ghimport from the parser packageCentralize host-aware REST client construction (
remote_fetch.go)newRESTClientForHost(host string)helper, replacing three identical inlineif host != "" { NewRESTClient(...) } else { DefaultRESTClient() }blocks