-
Notifications
You must be signed in to change notification settings - Fork 327
[plan] Replace gh repo view with repository.Current() #5829
Copy link
Copy link
Closed
Labels
Description
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
-
gh.Exec("repo", "view", ...)replaced withrepository.Current() - Import
github.com/cli/go-gh/v2/pkg/repositoryadded - Error handling preserved
- All unit tests pass (
make test-unit) - Code builds successfully (
make build)
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
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Type
Fields
Give feedbackNo fields configured for issues without a type.