Skip to content

feat: limit searching issues based on type#2186

Merged
bitwiseman merged 5 commits intohub4j:mainfrom
Anonycoders:gh-search-pr-issues
Mar 24, 2026
Merged

feat: limit searching issues based on type#2186
bitwiseman merged 5 commits intohub4j:mainfrom
Anonycoders:gh-search-pr-issues

Conversation

@Anonycoders
Copy link
Copy Markdown
Contributor

Description

Changes

  • isPullRequest => filter issues down to pull_requests only.
  • isIssue => filter issues down to issue only.
  • repo => allow limit the search to a specific repository of given organization.

https://docs.github.com/en/search-github/searching-on-github/searching-issues-and-pull-requests#search-only-issues-or-pull-requests

Before submitting a PR:

  • Changes must not break binary backwards compatibility. If you are unclear on how to make the change you think is needed while maintaining backward compatibility, CONTRIBUTING.md for details.
  • Add JavaDocs and other comments explaining the behavior.
  • When adding or updating methods that fetch entities, add @link JavaDoc entries to the relevant documentation on https://docs.github.com/en/rest .
  • Add tests that cover any added or changed code. This generally requires capturing snapshot test data. See CONTRIBUTING.md for details.
  • Run mvn -D enable-ci clean install site "-Dsurefire.argLine=--add-opens java.base/java.net=ALL-UNNAMED" locally. If this command doesn't succeed, your change will not pass CI.
  • Push your changes to a branch other than main. You will create your PR from that branch.

When creating a PR:

  • Fill in the "Description" above with clear summary of the changes. This includes:
    • If this PR fixes one or more issues, include "Fixes #" lines for each issue.
    • Provide links to relevant documentation on https://docs.github.com/en/rest where possible. If not including links, explain why not.
  • All lines of new code should be covered by tests as reported by code coverage. Any lines that are not covered must have PR comments explaining why they cannot be covered. For example, "Reaching this particular exception is hard and is not a particular common scenario."
  • Enable "Allow edits from maintainers".

@codecov
Copy link
Copy Markdown

codecov bot commented Jan 25, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.06%. Comparing base (9152b37) to head (fbc13d5).
⚠️ Report is 19 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #2186      +/-   ##
============================================
+ Coverage     85.03%   85.06%   +0.02%     
- Complexity     2499     2503       +4     
============================================
  Files           237      237              
  Lines          7366     7371       +5     
  Branches        388      388              
============================================
+ Hits           6264     6270       +6     
+ Misses          871      870       -1     
  Partials        231      231              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

* @return the gh issue search builder
*/
public GHIssueSearchBuilder isIssue() {
return q("is:issue");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method should also ensure that is:pr is removed if present.

* @return the gh issue search builder
*/
public GHIssueSearchBuilder isPullRequest() {
return q("is:pr");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method should also ensure that is:issue is removed if present.

Comment thread src/test/java/org/kohsuke/github/AppTest.java
.sort(GHIssueSearchBuilder.Sort.UPDATED)
.list();
assertThat(r.getTotalCount(), greaterThan(0));
for (GHIssue issue : r) {
Copy link
Copy Markdown
Member

@bitwiseman bitwiseman Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anyway to shorten the return list? If we can test this without storing several pages of json that we don't really care about.
Maybe isClosed() and sort.CREATED, then read the first few records?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm fair request! 👍🏼

.isPullRequest()
.isOpen()
.sort(GHIssueSearchBuilder.Sort.UPDATED)
.list();
Copy link
Copy Markdown
Member

@bitwiseman bitwiseman Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anyway to shorten the return list? If we can test this without storing several pages of json that we don't really care about.

Maybe isClosed() and sort.CREATED, then read the first few records?

@bitwiseman bitwiseman merged commit b888639 into hub4j:main Mar 24, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add more methods to QueryBuilder

2 participants