Skip to content

gh cli returns different (and incorrect) first entry than what is returned from the ui #9067

Closed

Description

@yassinm

Describe the bug

A clear and concise description of what the bug is. Include version by typing gh --version.

 -→ gh version
gh version 2.49.1 (2024-05-08)
https://github.com/cli/cli/releases/tag/v2.49.1

 -→ cat /etc/os-release 
BUG_REPORT_URL="https://github.com/NixOS/nixpkgs/issues"
BUILD_ID="23.11.6418.e402c3eb6d88"
DOCUMENTATION_URL="https://nixos.org/learn.html"
HOME_URL="https://nixos.org/"
ID=nixos
LOGO="nix-snowflake"
NAME=NixOS
PRETTY_NAME="NixOS 23.11 (Tapir)"
SUPPORT_END="2024-06-30"
SUPPORT_URL="https://nixos.org/community.html"
VERSION="23.11 (Tapir)"
VERSION_CODENAME=tapir
VERSION_ID="23.11"

I am trying to find the last issue number in the repo. i use that to create an issue automatically. its alrways returning the wrong results

Steps to reproduce the behavior

  1. Type this gh issue list -L 10 --repo unnug/pf-track --search "sort:created-desc" --json number --jq '.[].number'
  2. View the output
562
332
331
330
329
  1. See error

Expected vs actual behavior

the ui is correctly reporting the right results as per the attached screencshots

Logs

The first entry in descending order should be issue #631 i am not sure why it is returningthe above

image

Activity

  1. arunsathiya commented on May 9, 2024

    @arunsathiya
    Contributor

    Unless I am misreading something, the UI on your screenshot is showing closed issues while the CLI query is for open issues.

    Could you use the --state flag with closed? That should show closed issues, only. Other supported values are open and all

  2. yassinm commented on May 10, 2024

    @yassinm
    Author

    Unless I am misreading something, the UI on your screenshot is showing closed issues while the CLI query is for open issues.

    Could you use the --state flag with closed? That should show closed issues, only. Other supported values are open and all

    --state all is what i needed exactly ! as you said the ui is implicitly using closed while the cli is again implicitly using open without telling the user about what the query is implicitly using.

    Do you think it would make sense to add a hint on the ui/cli to infomr the user what implicit settings are being passed ?

    Bast Regards and thank you sooo much !!!

  3. williammartin commented on May 10, 2024

    @williammartin
    Member

    Thanks @arunsathiya for triaging this.

    Do you think it would make sense to add a hint on the ui/cli to infomr the user what implicit settings are being passed ?

    It's in issue list --help:

    -s, --state string Filter by state: {open|closed|all} (default "open")

    And if you run gh issue list the green is used to indicate state as well:

    Image

    That said, I would be open to adding a little extra info in the issue list Long description. Do you think it would have helped you if issue list --help would have said:

    List issues in a GitHub repository. By default this only lists open issues.
    

    I'm not that keen to repeat information but I also don't want to ignore someone getting confused.

  4. yassinm commented on May 10, 2024

    @yassinm
    Author

    @williammartin thank you so much for this detailed answer and your keen suggestion

    what i missed is the --state flag that can be passed.

    1. if you can add an example to the gh issue list --help showing how to use state
      $ gh issue list --state all --search "sort:created-desc"
    
    1. as you mentioned something along the lines of
    List issues in a GitHub repository. By default (if no --state flag is passed)  this only lists open issues.
    
  5. williammartin commented on May 10, 2024

    @williammartin
    Member

    if you can add an example to the gh issue list --help showing how to use state

    Great idea.

    I've added the help wanted label if you'd be up for contributing those changes.

    Cheers!

  6. babakks commented on May 29, 2024

    @babakks
    Member

    @yassinm If you'd like to contribute these changes, you can edit the command description/examples here:

    Long: heredoc.Doc(`
    List issues in a GitHub repository.
    The search query syntax is documented here:
    <https://docs.github.com/en/search-github/searching-on-github/searching-issues-and-pull-requests>
    `),
    Example: heredoc.Doc(`
    $ gh issue list --label "bug" --label "help wanted"
    $ gh issue list --author monalisa
    $ gh issue list --assignee "@me"
    $ gh issue list --milestone "The big 1.0"
    $ gh issue list --search "error no:assignee sort:created-asc"
    `),

  7. babakks commented on May 29, 2024

    @babakks
    Member

    @williammartin If we're adding this, why not add a similar example to gh pr list?

  8. williammartin commented on May 30, 2024

    @williammartin
    Member

    If we're adding this, why not add a similar example to gh pr list?

    Sounds like a nice idea to me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions