Skip to content

[Code Quality] Merge overlapping PRInfo and PullRequest structs in pkg/cli into a single PullRequest type #50882

Description

@github-actions

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 ·

  • expires on Aug 7, 2026, 5:22 AM UTC-08:00

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions