Objective
Replace the shell-out gh.Exec("repo", "view", ...) call with the native repository.Current() function for detecting the current repository.
Context
This is a quick win that eliminates unnecessary process spawning and provides cleaner, more idiomatic Go code. The native function also respects the GH_REPO environment variable automatically.
Files to Modify
- Update:
pkg/workflow/repository_features_validation.go (line ~182)
Current Implementation
stdOut, _, err := gh.Exec("repo", "view", "--json", "nameWithOwner", "-q", ".nameWithOwner")
if err != nil {
return "", fmt.Errorf("failed to get repository name: %w", err)
}
repo := strings.TrimSpace(stdOut.String())
Target Implementation
import "github.com/cli/go-gh/v2/pkg/repository"
repo, err := repository.Current()
if err != nil {
return "", fmt.Errorf("failed to get repository name: %w", err)
}
repoName := fmt.Sprintf("%s/%s", repo.Owner(), repo.Name())
Acceptance Criteria
Expected Impact
- Performance: ~5-10x faster (no process spawning)
- Code Quality: More readable and maintainable
- Reliability: Better error messages from native function
Estimated Effort
5-10 minutes
Related to #5828
AI generated by Plan Command for discussion #5826
Objective
Replace the shell-out
gh.Exec("repo", "view", ...)call with the nativerepository.Current()function for detecting the current repository.Context
This is a quick win that eliminates unnecessary process spawning and provides cleaner, more idiomatic Go code. The native function also respects the
GH_REPOenvironment variable automatically.Files to Modify
pkg/workflow/repository_features_validation.go(line ~182)Current Implementation
Target Implementation
Acceptance Criteria
gh.Exec("repo", "view", ...)replaced withrepository.Current()github.com/cli/go-gh/v2/pkg/repositoryaddedmake test-unit)make build)Expected Impact
Estimated Effort
5-10 minutes
Related to #5828