Sitelet https://web.archive.org/web/20200919055307/https://github.com/cli/cli/issues/1809
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

`gh pr list --state closed` returns `MERGED` #1809

Open
rynop opened this issue Sep 18, 2020 · 4 comments
Open

`gh pr list --state closed` returns `MERGED` #1809

rynop opened this issue Sep 18, 2020 · 4 comments

Comments

@rynop
Copy link

@rynop rynop commented Sep 18, 2020

Describe the bug

gh pr list --state closed returns PRs in MERGED state. Same output as if you ran the gh pr list --state merged command.

gh version 1.0.0 (2020-09-16)
https://github.com/cli/cli/releases/tag/v1.0.0

Steps to reproduce the behavior

  1. gh pr list --state closed | grep -i merged
  2. See output that contains MERGED PRs

Expected vs actual behavior

Expect to see only a list of PRs in the closed state

Logs

gh pr list --state closed | grep -i merged
5056	Add counters for socket connections	<branch/redacted>	MERGED
@rynop rynop added the bug label Sep 18, 2020
@mislav
Copy link
Member

@mislav mislav commented Sep 18, 2020

Sorry, this is by design! We wanted to reflect the web UI as much as possible, and there "closed" also includes "merged": https://github.com/cli/cli/pulls?q=is%3Apr+is%3Aclosed

How could we make this clearer? I'm guessing you really need a true closed filter?

@vilmibm vilmibm added needs-user-input and removed bug labels Sep 18, 2020
@rynop
Copy link
Author

@rynop rynop commented Sep 18, 2020

Thanks for the quick response. :TIL: closed includes merged. Makes sense.

TL;DR: adding /branches support to gh would be 🥇

What I'm really looking for, is exposing the data web UI does at /branches, in gh. Specifically, /branches/stale.

I'd like to clean up my branches - getting rid of ones that were associated with PRs that were closed or merged, and ones that are very old. The "associated with merged PRs" was easy with the new gh pr list --state closed (thanks for that BTW).

I know some of this can be done with just git but its semi-complex (especially with PR squash merges), which makes me anxious/nervous... There are OSS tools [1] but would rather use a tool maintained/vetted/battle-tested by GH.

@mislav
Copy link
Member

@mislav mislav commented Sep 18, 2020

@rynop I see! Thanks; that's valuable insight.

For now you can request the PR list manually via the API:

gh api -XGET repos/:owner/:repo/pulls -f state=closed -f per_page=100 | \
  jq -r '.[] | [.number,.title,.state,.head.label] | @tsv'

This will return true closed PRs, no merged.

@Galunid
Copy link

@Galunid Galunid commented Sep 18, 2020

@rynop I see! Thanks; that's valuable insight.

For now you can request the PR list manually via the API:

gh api -XGET repos/:owner/:repo/pulls -f state=closed -f per_page=100 | \
  jq -r '.[] | [.number,.title,.state,.head.label] | @tsv'

This will return true closed PRs, no merged.

Actually I don't think it returns true closed PRs. One of the results is
6601 Fix a few typos closed Galunid:patch
koreader/koreader#6601
It seems it returns merged PR as closed too

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.