Description
pkg/cli has two separate structs representing a GitHub pull request fetched via gh pr view, with non-overlapping fields:
PRInfo (pkg/cli/pr_command.go:28): Number, Title, Body, State, HeadSHA, BaseBranch, HeadBranch, SourceRepo, TargetRepo, AuthorLogin
PullRequest (pkg/cli/pr_automerge.go:21): Number, Title, IsDraft, Mergeable, CreatedAt, UpdatedAt
Both represent the same GitHub entity in the same package, causing confusion about which type to use and duplicated fetch/parse logic.
Suggested Changes
- Define a single
PullRequest struct in pkg/cli containing the union of fields both call sites need
- Update
pr_command.go and pr_automerge.go to use the unified type
- Update any
gh pr view --json field lists to fetch the union of needed fields in one place
- Remove the now-redundant
PRInfo type once all call sites are migrated
Files Affected
pkg/cli/pr_command.go
pkg/cli/pr_automerge.go
Success Criteria
- Only one PR-representation struct exists in
pkg/cli
- All existing PR command and automerge tests pass
- No loss of fields/functionality at either call site
Source
Extracted from Typist - Go Type Consistency Analysis #50840
Priority
Medium - reduces confusing duplication of core domain type; effort ~2-3 hours
🔍 Task mining by Discussion Task Miner - Code Quality Improvement Agent · auto · 32.7 AIC · ⌖ 3.82 AIC · ⊞ 10.2K · ◷
Description
pkg/clihas two separate structs representing a GitHub pull request fetched viagh pr view, with non-overlapping fields:PRInfo(pkg/cli/pr_command.go:28):Number, Title, Body, State, HeadSHA, BaseBranch, HeadBranch, SourceRepo, TargetRepo, AuthorLoginPullRequest(pkg/cli/pr_automerge.go:21):Number, Title, IsDraft, Mergeable, CreatedAt, UpdatedAtBoth represent the same GitHub entity in the same package, causing confusion about which type to use and duplicated fetch/parse logic.
Suggested Changes
PullRequeststruct inpkg/clicontaining the union of fields both call sites needpr_command.goandpr_automerge.goto use the unified typegh pr view --jsonfield lists to fetch the union of needed fields in one placePRInfotype once all call sites are migratedFiles Affected
pkg/cli/pr_command.gopkg/cli/pr_automerge.goSuccess Criteria
pkg/cliSource
Extracted from Typist - Go Type Consistency Analysis #50840
Priority
Medium - reduces confusing duplication of core domain type; effort ~2-3 hours