-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Use advanced issue search #11638
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
Use advanced issue search #11638
Conversation
Signed-off-by: Babak K. Shandiz <babakks@github.com>
Signed-off-by: Babak K. Shandiz <babakks@github.com>
Signed-off-by: Babak K. Shandiz <babakks@github.com>
Signed-off-by: Babak K. Shandiz <babakks@github.com>
Signed-off-by: Babak K. Shandiz <babakks@github.com>
Signed-off-by: Babak K. Shandiz <babakks@github.com>
Signed-off-by: Babak K. Shandiz <babakks@github.com>
Signed-off-by: Babak K. Shandiz <babakks@github.com>
Signed-off-by: Babak K. Shandiz <babakks@github.com>
Signed-off-by: Babak K. Shandiz <babakks@github.com>
Signed-off-by: Babak K. Shandiz <babakks@github.com>
Signed-off-by: Babak K. Shandiz <babakks@github.com>
Signed-off-by: Babak K. Shandiz <babakks@github.com>
…eSearchString` methods Signed-off-by: Babak K. Shandiz <babakks@github.com>
Signed-off-by: Babak K. Shandiz <babakks@github.com>
Signed-off-by: Babak K. Shandiz <babakks@github.com>
Signed-off-by: Babak K. Shandiz <babakks@github.com>
Signed-off-by: Babak K. Shandiz <babakks@github.com>
… syntax Signed-off-by: Babak K. Shandiz <babakks@github.com>
Signed-off-by: Babak K. Shandiz <babakks@github.com>
Signed-off-by: Babak K. Shandiz <babakks@github.com>
Signed-off-by: Babak K. Shandiz <babakks@github.com>
Signed-off-by: Babak K. Shandiz <babakks@github.com>
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.
Pull Request Overview
This PR updates the GitHub CLI to use advanced issue search functionality when available, with backward compatibility for GHES 3.17 and older versions. The changes include enhanced search query formatting with OR operators, feature detection for advanced search capabilities, and comprehensive test updates.
Key changes:
- Added feature detection for advanced issue search with different support levels (unsupported, opt-in, only backend)
- Enhanced query formatting to support advanced syntax with OR operators for special qualifiers
- Updated all search-related commands to use the new searcher interface with feature detection
Reviewed Changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
pkg/search/searcher.go |
Added feature detection and conditional query formatting for advanced issue search |
pkg/search/query.go |
Implemented advanced issue search string formatting with OR grouping for special qualifiers |
pkg/search/searcher_test.go |
Updated tests to include detector parameter and added advanced syntax test cases |
internal/featuredetection/feature_detection.go |
Added SearchFeatures detection with version checking and GraphQL schema introspection |
pkg/cmd/pr/list/http.go |
Updated search functions to use feature detection for proper search type selection |
pkg/cmd/issue/list/http.go |
Updated issue search to conditionally use advanced syntax based on feature detection |
Comments suppressed due to low confidence (1)
pkg/search/query.go:1
- The advanced search logic handles grouping of special qualifiers like 'is:blocked' and 'is:blocking', but there's no documentation explaining why these specific values are grouped together. Consider adding a comment explaining the semantic relationship between these paired qualifiers.
package search
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
…ssue search Signed-off-by: Babak K. Shandiz <babakks@github.com>
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.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
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.
Still working through it, but some ideas for the help docs you might be interested in.
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.
Looks good; I left some comments. I think some of these things could be improved like removing the extra feature detector variable, if we'd like to do it in this PR, but that and all my other comments are minor and not blocking. I think it's clear that this PR as-is resolves the problems we needed to fix and does good job explaining what those problems are as well 👍
I particularly thought the query formatter you setup was a neat way of solving the problem. And I admire the attention to detail in the tests :)
Signed-off-by: Babak K. Shandiz <babakks@github.com>
Signed-off-by: Babak K. Shandiz <babakks@github.com>
Signed-off-by: Babak K. Shandiz <babakks@github.com>
Signed-off-by: Babak K. Shandiz <babakks@github.com>
Signed-off-by: Babak K. Shandiz <babakks@github.com>
Signed-off-by: Babak K. Shandiz <babakks@github.com>
Signed-off-by: Babak K. Shandiz <babakks@github.com>
…esTab` field Signed-off-by: Babak K. Shandiz <babakks@github.com>
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.
Thanks for the feedback round! LGTM!
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This MR contains the following updates: | Package | Update | Change | |---|---|---| | [cli/cli](https://github.com/cli/cli) | minor | `v2.78.0` -> `v2.79.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.79.0`](https://github.com/cli/cli/releases/tag/v2.79.0): GitHub CLI 2.79.0 [Compare Source](cli/cli@v2.78.0...v2.79.0) #### Advanced Issue Search Support The GitHub CLI now supports advanced issue search syntax using: - Searching issues: `gh search issues <advanced issue search query>` - Searching pull requests: `gh search prs <advanced issue search query>` - While listing issues: `gh issue list --search <advanced issue search query>` - While listing pull requests: `gh pr list --search <advanced issue search query>` For more information about advanced issue search syntax, see: "[Filtering and Searching Issues and Merge Requests](https://docs.github.com/en/issues/tracking-your-work-with-issues/using-issues/filtering-and-searching-issues-and-pull-requests#building-advanced-filters-for-issues)" #### Copy OAuth Code Automatically The GitHub CLI now supports writing the OAuth one-time pass code to the clipboard automatically during authentication: - While logging in: `gh auth login --clipboard` / `gh auth login -c` - While refreshing the token: `gh auth refresh --clipboard` / `gh auth refresh -c` #### What's Changed ##### ✨ Features - feat: `gh auth` Automatically copy one-time OAuth code to clipboard by [@​ankddev](https://github.com/ankddev) in [#​11518](cli/cli#11518) - feat: add support for `--ref` in `gh cache delete` by [@​luxass](https://github.com/luxass) in [#​11592](cli/cli#11592) - Use advanced issue search by [@​babakks](https://github.com/babakks) in [#​11638](cli/cli#11638) ##### 📚 Docs & Chores - docs(release create): difference `--generate-notes` and `--notes-from-tag` by [@​ankddev](https://github.com/ankddev) in [#​11534](cli/cli#11534) - refactor tests: use `slices.Equal` to simplify code by [@​minxinyi](https://github.com/minxinyi) in [#​11364](cli/cli#11364) - Remove mention of public preview in trustedroot.go by [@​jkylekelly](https://github.com/jkylekelly) in [#​11652](cli/cli#11652) #####Dependencies - Bump sigstore/rekor to v1.4.1 by [@​BagToad](https://github.com/BagToad) in [#​11654](cli/cli#11654) - chore(deps): bump actions/stale from 9 to 10 by [@​dependabot](https://github.com/dependabot)\[bot] in [#​11663](cli/cli#11663) - chore(deps): bump actions/setup-go from 5 to 6 by [@​dependabot](https://github.com/dependabot)\[bot] in [#​11662](cli/cli#11662) #### New Contributors - [@​minxinyi](https://github.com/minxinyi) made their first contribution in [#​11364](cli/cli#11364) - [@​jkylekelly](https://github.com/jkylekelly) made their first contribution in [#​11652](cli/cli#11652) - [@​luxass](https://github.com/luxass) made their first contribution in [#​11592](cli/cli#11592) **Full Changelog**: <cli/cli@v2.78.0...v2.79.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:eyJjcmVhdGVkSW5WZXIiOiI0MS45OC4xIiwidXBkYXRlZEluVmVyIjoiNDEuOTguMSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiUmVub3ZhdGUgQm90Il19-->
This PR updates
ghto use advanced issue search, if available.Here are a couple of notes regarding the changes:
The
searchpackage (inpkg/search) is a general-purpose/independent component that handles the search for a couple of other commands. That is why, it now supportsis:blocked,is:blockingor even handles the combination ofis:mergedandis:unmergedin a query, although no other part of the code actually uses these. It's just to eliminate the extra knowledge about what other packages need.For mock feature detectors, where a feature detector was need but it's not really important for the test case (like asserting something other than the query), a mock that reflects the current status of the advanced issue search is used (which is supported as opt-in). This is to keep the tests up-to-date with the state of
github.comand reflect the fact thatghprefers advanced issue search if it's available on the host.For test cases where the code path should not involve any feature detection (e.g. when a list operation should take place, rather than a search), a
nildetector is passed.Two markers added to the code to help us identify the places we need to change in the future:
// TODO advancedIssueSearchCleanup: actionable when GHES 3.17 goes out of support and we don't need to maintain compatibility with the old issue search backend.// TODO advancedSearchFuture: actionable when the advanced search syntax is available on global search or Pull Requests tabs.A/C verification
A. On
github.com1.
gh search issues(REST API)All confirmed, just an example here. HTTP request (note the
advanced_search=true):URL-decoded query:
Confirmed:

2.
gh search prs(REST API)All confirmed, just an example here. HTTP request (note the
advanced_search=true):URL-decoded query:
Confirmed:

3.
gh issue list(GraphQL)Confirmed (note the
ISSUE_ADVANCED):The results are the same:
Confirmed. On latest

gh:Current PR:

4.
gh pr list(GraphQL)Confirmed (note the
ISSUE_ADVANCED):The results are the same:
Confirmed. On latest

gh:Current PR:

B. On GHES 3.17
Asserting the GHES instance version:
1.
gh search issues(REST API)Confirmed. Both show the same output (although expected 2, not 2x2 hits!):
Also, no
advanced_search=trueand noORs in query in the HTTP request:Confirmed; since the GUI does not show the query here's the browser's address bar:

2.
gh search prs(REST API)Confirmed. Both show the same output (this time really 2 hits!):
Also, no
advanced_search=trueand noORs in query in the HTTP request:Confirmed; since the GUI does not show the query here's the browser's address bar:

3.
gh issue list(GraphQL)Confirmed the outputs are the same (although it should be only one hit, not two!):
Also
typeisISSUE:Confirmed. On latest

gh:Current PR:

4.
gh pr list(GraphQL)Confirmed the outputs are the same:
Also
typeisISSUE:Confirmed. On latest

gh:Current PR:
