Repository navigation
[refactor] Duplicate SHA-resolution logic in resolveSetupActionModeRef/resolveSetupReleaseModeRef #70752
Description
Overview
Sampled analysis (slice 9/631 of pkg/workflow, slice 9/11 of pkg/workflow/actions; date 2026-10-21; coverage_days 793 for the full rotation) reviewed 14 functions across 4 files. This is a sampled excerpt review, not a claim of full-package or full-repository coverage.
Finding
pkg/workflow/action_reference.go has two functions with near-identical control flow that differ only in how actionRepo is derived and in a log-label string:
resolveSetupActionModeRef(lines 66-79)resolveSetupReleaseModeRef(lines 81-95)
Both functions:
- Call
resolveSetupTag(actionTag, version, localPath)and returnlocalPathearly if!ok. - Build
remoteRef := fmt.Sprintf("%s@%s", actionRepo, tag). - Call
tryResolveSetupSHA(ctx, resolver, actionRepo, tag, remoteRef, modeLabel)and return the resolved ref if non-empty. - Otherwise log a warning via
actionRefLog.Printfwith a mode-specific message and returnremoteRef.
The only differences are the actionRepo construction (actionsOrgRepo + "/setup" vs. fmt.Sprintf("%s/%s", GitHubOrgRepo, strings.TrimPrefix(localPath, "./"))) and the mode label text ("Action mode" / "Release mode", plus slightly different wording in the final log message: "external actions repo reference" vs. "remote action reference").
Observed source (from the sampled packet)
func resolveSetupActionModeRef(ctx context.Context, actionTag string, version string, resolver SHAResolver, actionsOrgRepo string, localPath string) string {
tag, ok := resolveSetupTag(actionTag, version, localPath)
if !ok {
return localPath
}
actionRepo := actionsOrgRepo + "/setup"
remoteRef := fmt.Sprintf("%s@%s", actionRepo, tag)
ref := tryResolveSetupSHA(ctx, resolver, actionRepo, tag, remoteRef, "Action mode")
if ref != "" {
return ref
}
actionRefLog.Printf("Action mode: using tag-based external actions repo reference: %s (SHA will be resolved later)", remoteRef)
return remoteRef
}
func resolveSetupReleaseModeRef(ctx context.Context, actionTag string, version string, resolver SHAResolver, localPath string) string {
tag, ok := resolveSetupTag(actionTag, version, localPath)
if !ok {
return localPath
}
actionPath := strings.TrimPrefix(localPath, "./")
actionRepo := fmt.Sprintf("%s/%s", GitHubOrgRepo, actionPath)
remoteRef := fmt.Sprintf("%s@%s", actionRepo, tag)
ref := tryResolveSetupSHA(ctx, resolver, actionRepo, tag, remoteRef, "Release mode")
if ref != "" {
return ref
}
actionRefLog.Printf("Release mode: using tag-based remote action reference: %s (SHA will be resolved later)", remoteRef)
return remoteRef
}Both excerpts are complete (truncated: false) for the sampled byte range.
Proposed refactoring
Extract the shared tail into one helper, e.g.:
func resolveSetupModeRef(ctx context.Context, actionTag, version string, resolver SHAResolver, localPath, actionRepo, modeLabel string) string {
tag, ok := resolveSetupTag(actionTag, version, localPath)
if !ok {
return localPath
}
remoteRef := fmt.Sprintf("%s@%s", actionRepo, tag)
if ref := tryResolveSetupSHA(ctx, resolver, actionRepo, tag, remoteRef, modeLabel); ref != "" {
return ref
}
actionRefLog.Printf("%s: using tag-based reference: %s (SHA will be resolved later)", modeLabel, remoteRef)
return remoteRef
}Then resolveSetupActionModeRef and resolveSetupReleaseModeRef would each compute their own actionRepo and call this helper with their respective mode label.
Preservation risks
- The two log messages currently use slightly different wording ("external actions repo reference" vs. "remote action reference"); unifying the format string changes log text, which may affect anything scraping these logs.
- Both callers must be confirmed to tolerate the exact same
remoteRef/refsemantics — the sampled excerpts show no divergence, but the rest of each file was not reviewed.
Scope and limitations
This is a sampled analysis of 14 functions in 4 files (per the daily rotation), not a review of the entire workflow or actions package. No other significant duplicate-logic or purpose-mismatch findings were confirmed in this sample.
Generated by 🔧 Semantic Function Refactoring · claude · sonnet50 · 27.6 AIC · ⌖ 19.1 AIC · ⊞ 5.1K · ◷
- expires on Oct 22, 2026, 6:39 PM UTC-08:00
Activity
github-actions commentedon Oct 22, 2026
Superseded by the newest sampled semantic-function-refactor report (slice 1/1 for pkg/linters/contextcancelnotdeferred and pkg/linters/ctxbackground, 2026-10-22). Closing as part of the rolling refactor-suggestion backlog.