Skip to content

Prevent pr commands without arguments from accidentally applying to defunct, closed PRs #4263

@mislav

Description

@mislav

When you run gh pr view, for example, we will look up the current branch and display the latest PR that has it as its head branch. We do this even for closed PRs so that operations like gh pr view and gh pr reopen can work.

When one is on the default branch, however, I don't think the same logic should apply. Looking up closed PRs that have main as their head branch is most likely going to surface spammy or otherwise defunct PRs. I would suggest that the fix is to only scope the lookup to open PRs while on the default branch.

The starting point in our codebase for this would be:

pr, err = findForBranch(httpClient, f.repo, opts.BaseBranch, f.branchName, opts.States, fields.ToSlice())

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issuehelp wantedContributions welcomep3Affects a small number of users or is largely cosmetic

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions