Deduplicate commit-ref SHA resolution in action_resolver - #51472
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
PR Triage
|
There was a problem hiding this comment.
Pull request overview
Deduplicates commit-ref SHA resolution while preserving caller-specific diagnostics.
Changes:
- Adds a shared resolver with timeout, host forcing, validation, and enriched errors.
- Updates both callers to use the shared helper.
- Adds Wasm compatibility and initial tests.
Show a summary per file
| File | Description |
|---|---|
pkg/workflow/action_resolver.go |
Centralizes commit-ref resolution. |
pkg/workflow/github_cli_wasm.go |
Adds the Wasm error-enrichment stub. |
pkg/workflow/action_resolver_commit_ref_test.go |
Tests short-circuiting and cancellation. |
Review details
Tip
Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
- Files reviewed: 3/3 changed files
- Comments generated: 1
- Review effort level: Balanced
| func TestResolveCommitRefSHACancelledContext(t *testing.T) { | ||
| ctx, cancel := context.WithCancel(context.Background()) | ||
| cancel() | ||
|
|
||
| sha, err := resolveCommitRefSHA(ctx, "github/gh-aw", "main") |
|
@copilot Please refresh this branch if needed, address any remaining review feedback, and run the pr-finisher skill.
|
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Added fake-gh PATH tests in commit covering: stdout-only SHA parsing (stderr noise doesn't contaminate the returned SHA), nonzero exit surfaced as plain error and not |
PR Triage
|
pkg/workflow/action_resolver.gohad two independent implementations of "resolve a ref to a commit SHA viagh api /repos/.../commits/{ref} --jq .sha" — one inresolveRefViaCommitsEndpoint, one inResolveGhAwRef. They had already drifted (OutputvsCombinedOutput,GH_HOSTforced in only one path), making future fixes easy to apply inconsistently.Changes
resolveCommitRefSHA(ctx, repoSlug, ref)owns path construction, the 30s timeout,ExecGHContextinvocation,ForceGHHostEnv, output trimming, and full-SHA validation.ResolveGhAwRefretains its full-SHA short-circuit.notFullCommitSHAErrorcarries the raw response so each caller can still emit its own "unexpected response resolving …" message without the helper needing a second return value.ResolveGhAwRefnow usesOutput()+enrichGHErrorinstead ofCombinedOutput(). Stderr still reaches the error message, but can no longer contaminate the parsed SHA.ResolveGhAwRefnow forcesGH_HOST=github.com, so a GHE host in the environment can't hijack a lookup that always targetsgithub/gh-aw.enrichGHErrorstub ingithub_cli_wasm.go(it previously lived only in the non-wasm file).action_resolver_commit_ref_test.gocovers the full-SHA short-circuit and asserts command failures are not misreported asnotFullCommitSHAError.run: https://github.com/github/gh-aw/actions/runs/31293411688> Generated by 👨🍳 PR Sous Chef · gpt54 · 3.76 AIC · ⌖ 6.55 AIC · ⊞ 8.5K · ◷