-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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:stale URL path: https://api.github.com/search/issues?page=1&per_page=30&q=distribution+repo%3Arubyforgood%2Fhuman-essentials+-label%3A+stale+type%3Aissue Problem: ❌ 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%3Aissue Problem: 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%3Aissue Result: |
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.
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.
🍻
Fixes #10480
This PR improves the
gh search
docs by explaining the usage of (--
) when using GitHub search syntax as query to exclude results based on qualifiers.Docs for the following
gh
commands are updated:gh search code
gh search commit
gh search issues
gh search prs
gh search repos
Looking 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:stale
Issue: results included issues with the
stale
labelReferences 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