You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Recent-commit duplicate analysis found one significant structural duplication pattern in pkg/workflow/github_cli.go introduced/expanded during context-propagation work.
The two internal helpers runGHWithSpinnerContext and runGHWithSpinner are nearly identical across ~24 lines each, differing mainly in command construction (ExecGHContext vs ExecGH). This exceeds the duplication threshold (>10 lines).
Critical Information
Pattern: Near-identical helper functions with only command-constructor variance
Maintainability: Future fixes to one path can be missed in the other.
Bug Risk: Error-enrichment/spinner behavior can diverge subtly across context and non-context invocations.
Code Bloat: Duplicate logic in a central command-execution utility.
Refactoring Recommendations
Extract a single executor that accepts a command factory
Suggested target: pkg/workflow/github_cli.go
Approach: one private helper like runGHWithSpinnerCmd(cmd *exec.Cmd, spinnerMessage string, combined bool) and keep thin wrappers for context/non-context command construction.
Estimated effort: 1-2 hours
Benefit: single execution path for spinner and output handling
Add focused regression tests for both wrappers
Ensure both wrappers share identical behavior for:
TTY/non-TTY branches
combined=true/false
error enrichment
Estimated effort: 1 hour
Implementation Checklist
Consolidate duplicated execution logic into one private helper
Keep API compatibility for RunGH* functions
Add/adjust tests for context and non-context parity
Validate no behavior change in existing callers
Analysis Metadata
Analyzed files: 15 non-test .go/.cjs files from latest commits
Detection method: Serena symbol analysis + patch inspection
Overview
Recent-commit duplicate analysis found one significant structural duplication pattern in
pkg/workflow/github_cli.gointroduced/expanded during context-propagation work.The two internal helpers
runGHWithSpinnerContextandrunGHWithSpinnerare nearly identical across ~24 lines each, differing mainly in command construction (ExecGHContextvsExecGH). This exceeds the duplication threshold (>10 lines).Critical Information
pkg/workflow/github_cli.go:101pkg/workflow/github_cli.go:129Duplication Details
Pattern Details
Both functions execute the same control flow:
combinedto useCombinedOutputvsOutputenrichGHErrorto non-combined pathOnly the command creation line changes:
cmd := ExecGHContext(ctx, args...)cmd := ExecGH(args...)Code Example
Impact Analysis
Refactoring Recommendations
pkg/workflow/github_cli.gorunGHWithSpinnerCmd(cmd *exec.Cmd, spinnerMessage string, combined bool)and keep thin wrappers for context/non-context command construction.combined=true/falseImplementation Checklist
RunGH*functionsAnalysis Metadata
.go/.cjsfiles from latest commitse44f4e7fec20d266caec65919fa1a8ac57948e50,920a4e8bdf57936b61774d9a82be8eb1e20c109c,f3831d82a6662de794d85a418d368c6dede6b115References:
Warning
The following domains were blocked by the firewall during workflow execution:
ab.chatgpt.comapi.github.comchatgpt.comgithub.comTo allow these domains, add them to the
network.allowedlist in your workflow frontmatter:See Network Configuration for more information.