-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Adding a note to gh search docs to explain the usage of -- to exclude certain results
#11162
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
Conversation
To investigate, I spoke with @BagToad, and we found that the request URL is not encoded correctly for certain query patterns. Note We used ❌ Command 1gh search issues -- distribution repo:rubyforgood/human-essentials -label:staleURL path: https://api.github.com/search/issues?page=1&per_page=30&q=distribution+repo%3Arubyforgood%2Fhuman-essentials+-label%3A+stale+type%3AissueProblem: ❌ Command 2: Full query in quotesgh search issues -- 'distribution repo:rubyforgood/human-essentials -label:stale'Request URL: https://api.github.com/search/issues?page=1&per_page=30&q=distribution+repo%3A%22rubyforgood%2Fhuman-essentials+-label%3Astale%22+type%3AissueProblem: Invalid search query "distribution repo:\"rubyforgood/human-essentials -label:stale\" type:issue".✅ Command 3: Only exclusion part quotedgh search issues -- distribution repo:rubyforgood/human-essentials '-label:stale'Request URL: https://api.github.com/search/issues?page=1&per_page=30&q=distribution+repo%3Arubyforgood%2Fhuman-essentials+-label%3Astale+type%3AissueResult: |
|
I noticed that the For example, the following command:
runs without problems in |
|
The unix stop parse character
☝️ the |
899d63c to
45876ed
Compare
Introduces a new help topic explaining how to use exclusion qualifiers in GitHub search syntax with gh commands, including platform-specific instructions for Unix-like systems and PowerShell. Provides links to relevant documentation for further reference. Co-Authored-By: Sid <41968447+sukhpreet-s@users.noreply.github.com>
|
@andyfeller I've been working with @Sukhpreet-s on this one. Most of the conversation up till this point has been trying to understand how powershell works in this case. @Sukhpreet-s wanted to make sure we're doing right by powershell users by ensuring our documentation is complete for all platforms. We decided that the explanation was too meaty to be in each Since I've been pretty in the weeds with this and I'm interested in your insight as the original issue author as to where you envisioned this might be documented, I requested your review. Another thing that came up was potentially moving this documentation to docs.github.com, but we decided to see what a help topic feels like first and get another opinion 🍻 |
|
Thanks for the ping, @BagToad! 🙇
Why I think
|
| if _, ok := command.Annotations["help:json-fields"]; ok { | |
| fields := strings.Split(command.Annotations["help:json-fields"], ",") | |
| helpEntries = append(helpEntries, helpEntry{"JSON FIELDS", text.FormatSlice(fields, 80, 0, "", "", true)}) | |
| } | |
| if _, ok := command.Annotations["help:arguments"]; ok { | |
| helpEntries = append(helpEntries, helpEntry{"ARGUMENTS", command.Annotations["help:arguments"]}) | |
| } | |
| if command.Example != "" { | |
| helpEntries = append(helpEntries, helpEntry{"EXAMPLES", command.Example}) | |
| } | |
| if _, ok := command.Annotations["help:environment"]; ok { | |
| helpEntries = append(helpEntries, helpEntry{"ENVIRONMENT VARIABLES", command.Annotations["help:environment"]}) | |
| } | |
| helpEntries = append(helpEntries, helpEntry{"LEARN MORE", heredoc.Docf(` | |
| Use %[1]sgh <command> <subcommand> --help%[1]s for more information about a command. | |
| Read the manual at https://cli.github.com/manual | |
| Learn about exit codes using %[1]sgh help exit-codes%[1]s | |
| Learn about accessibility experiences using %[1]sgh help accessibility%[1]s | |
| `, "`")}) |
|
@andyfeller and I discussed his thoughts a bit more and I wanted to summarize the next steps for this PR:
Do you feel comfortable making those changes? 🙂 |
|
@andyfeller Thank you for the explanation on the decision to move the note to Also, thank you @BagToad for simplifying the next steps ❤️✨ I have pushed the changes. 🚀 |
| Long: heredoc.Docf(` | ||
| Search across all of GitHub. | ||
| Excluding search results that match a qualifier |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wish there was a good way to make this appear more like a heading, but that's not something that should be solved in this PR. Just making a comment about it.
BagToad
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - thanks for taking the time with me to work through this one! It definitely turned out to be more complicated. The fact that you both found and helped address the PowerShell difference was great, and no doubt will save someone a bunch of time in the future.
🍻
This MR contains the following updates: | Package | Update | Change | |---|---|---| | [cli/cli](https://github.com/cli/cli) | minor | `v2.76.2` -> `v2.78.0` | MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot). **Proposed changes to behavior should be submitted there as MRs.** --- ### Release Notes <details> <summary>cli/cli (cli/cli)</summary> ### [`v2.78.0`](https://github.com/cli/cli/releases/tag/v2.78.0): GitHub CLI 2.78.0 [Compare Source](cli/cli@v2.77.0...v2.78.0) #### ℹ️ Note This release was cut primarily to resolve a Linux package distribution issue. We recommend reviewing [the v2.77.0 release notes](https://github.com/cli/cli/releases/tag/v2.77.0) for the complete set of latest features and fixes. #### What's Changed ##### ✨ Features - Add `--force` flag to `gh run cancel` by [@​ankddev](https://github.com/ankddev) in [#​11513](cli/cli#11513) ##### 🐛 Fixes - Fix failing to release Linux packages (affected v2.77.0). See [v2.77.0](https://github.com/cli/cli/releases/tag/v2.77.0) for more information. **Full Changelog**: <cli/cli@v2.77.0...v2.78.0> ### [`v2.77.0`](https://github.com/cli/cli/releases/tag/v2.77.0): GitHub CLI 2.77.0 [Compare Source](cli/cli@v2.76.2...v2.77.0) ####⚠️ Incomplete Release The v2.77.0 release experienced a failure publishing to our official Linux repos. This is resolved in [v2.78.0](https://github.com/cli/cli/releases/tag/v2.78.0), so we recommend using that release instead. #### What's Changed ##### ✨ Features - Report that v1 classic projects are detected on GHES 3.16.x or older by [@​andyfeller](https://github.com/andyfeller) in [#​11491](cli/cli#11491) - Display v2 projects in `gh issue view` by [@​andyfeller](https://github.com/andyfeller) in [#​11496](cli/cli#11496) - View v2 projects in `gh pr view` output by [@​andyfeller](https://github.com/andyfeller) in [#​11497](cli/cli#11497) - Ensure users can see v2 projects when viewing issues and MRs, avoid v1 projects on GHES 3.17 and newer by [@​andyfeller](https://github.com/andyfeller) in [#​11514](cli/cli#11514) ##### 🐛 Fixes - fix error for ErrReleaseNotFound when fetching ref by [@​ejahnGithub](https://github.com/ejahnGithub) in [#​11451](cli/cli#11451) - add test for FetchRefSHA by [@​ejahnGithub](https://github.com/ejahnGithub) in [#​11481](cli/cli#11481) - Fix `gh repo delete --yes` safety issue when no repository argument provided by [@​Copilot](https://github.com/Copilot) in [#​11536](cli/cli#11536) ##### 📚 Docs & Chores - Improve spam detection evals by [@​babakks](https://github.com/babakks) in [#​11419](cli/cli#11419) - Fix `help wanted` label regexp in CI automation by [@​babakks](https://github.com/babakks) in [#​11423](cli/cli#11423) - Update spam detection to comment on and close issue by [@​andyfeller](https://github.com/andyfeller) in [#​11435](cli/cli#11435) - Adding a note to `gh search` docs to explain the usage of `--` to exclude certain results by [@​Sukhpreet-s](https://github.com/Sukhpreet-s) in [#​11162](cli/cli#11162) - Update issue triage guidelines and label usage by [@​BagToad](https://github.com/BagToad) in [#​11454](cli/cli#11454) - Reorganize installation docs by [@​andyfeller](https://github.com/andyfeller) in [#​11473](cli/cli#11473) - Update govulncheck workflow to scan source code by [@​BagToad](https://github.com/BagToad) in [#​11482](cli/cli#11482) - Hidden trusted root flag for release verify by [@​ejahnGithub](https://github.com/ejahnGithub) in [#​11511](cli/cli#11511) #####Dependencies - Regenerate third-party licenses on trunk pushes by [@​andyfeller](https://github.com/andyfeller) in [#​11370](cli/cli#11370) - Update third-party license versions by [@​BagToad](https://github.com/BagToad) in [#​11557](cli/cli#11557) - Bump Go to 1.24.6 by [@​github-actions](https://github.com/github-actions)\[bot] in [#​11467](cli/cli#11467) - chore(deps): bump github.com/spf13/pflag from 1.0.6 to 1.0.7 by [@​dependabot](https://github.com/dependabot)\[bot] in [#​11319](cli/cli#11319) - chore(deps): bump actions/download-artifact from 4 to 5 by [@​dependabot](https://github.com/dependabot)\[bot] in [#​11458](cli/cli#11458) - chore(deps): bump actions/checkout from 4 to 5 by [@​dependabot](https://github.com/dependabot)\[bot] in [#​11490](cli/cli#11490) - chore(deps): bump github.com/yuin/goldmark from 1.7.12 to 1.7.13 by [@​dependabot](https://github.com/dependabot)\[bot] in [#​11368](cli/cli#11368) - Bump google.golang.org/grpc & other required dependencies by [@​BagToad](https://github.com/BagToad) in [#​11510](cli/cli#11510) - chore(deps): bump google.golang.org/grpc from 1.73.0 to 1.74.2 by [@​dependabot](https://github.com/dependabot)\[bot] in [#​11367](cli/cli#11367) - chore(deps): bump github.com/cli/go-gh/v2 from 2.12.1 to 2.12.2 by [@​dependabot](https://github.com/dependabot)\[bot] in [#​11537](cli/cli#11537) - chore(deps): bump github.com/go-viper/mapstructure/v2 from 2.3.0 to 2.4.0 by [@​dependabot](https://github.com/dependabot)\[bot] in [#​11556](cli/cli#11556) #### New Contributors - [@​Sukhpreet-s](https://github.com/Sukhpreet-s) made their first contribution in [#​11162](cli/cli#11162) - [@​Copilot](https://github.com/Copilot) made their first contribution in [#​11536](cli/cli#11536) **Full Changelog**: <cli/cli@v2.76.2...v2.77.0> </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this MR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box --- This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MS44Mi4xIiwidXBkYXRlZEluVmVyIjoiNDEuODIuMSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiUmVub3ZhdGUgQm90Il19-->
Fixes #10480
This PR improves the
gh searchdocs by explaining the usage of (--) when using GitHub search syntax as query to exclude results based on qualifiers.Docs for the following
ghcommands are updated:gh search codegh search commitgh search issuesgh search prsgh search reposLooking for feedback / Things to still figure out:
Any improvements in the language used for the note.
While testing the
--behaviour, I found that the--syntax does not work as expected on Powershell. This might require an addition to the docs notifying this unexpected behaviour to the users.Command I used to test on Powershell:
gh search issues distribution -- repo:rubyforgood/human-essentials -label:staleIssue: results included issues with the
stalelabelReferences used:
https://docs.github.com/en/search-github/searching-on-github/searching-issues-and-pull-requests
https://docs.github.com/en/search-github/getting-started-with-searching-on-github/understanding-the-search-syntax#exclude-results-that-match-a-qualifier
cli/pkg/cmd/search/prs/prs.go
Lines 34 to 35 in 2b89358