feat(api): add q parameter to list branches API for server-side filtering - #37982
Merged
Merged
Conversation
lunny
approved these changes
Jun 3, 2026
puni9869
approved these changes
Jun 3, 2026
wxiaoguang
reviewed
Jun 3, 2026
wxiaoguang
marked this pull request as draft
June 3, 2026 06:46
HarshMN2345
force-pushed
the
feat/branches-api-search
branch
from
June 3, 2026 07:09
adc937b to
0458a8e
Compare
Contributor
|
By the way, please don't rebase or force-push when reviewing started. https://github.com/go-gitea/gitea/blob/main/CONTRIBUTING.md#maintaining-open-prs |
wxiaoguang
marked this pull request as ready for review
June 3, 2026 07:14
Member
|
Is it really a FEATURE |
zeekay
pushed a commit
to hanzoai/forge
that referenced
this pull request
Jul 26, 2026
…ring (go-gitea#37982) The GET /repos/{owner}/{repo}/branches endpoint currently has no way to filter branches by name server-side, forcing API consumers to paginate through all branches and filter client-side. The UI already supports branch search (added in [go-gitea#27055](go-gitea#27055)). The underlying DB layer has a Keyword field on FindBranchOptions in models/git/branch_list.go that does a LIKE %keyword% SQL filter, it just wasn't wired up to the API handler. This PR exposes a ?q= query parameter on the endpoint that maps to FindBranchOptions.Keyword. Example: ```GET /repos/owner/repo/branches?q=feature ``` Closes go-gitea#37981 --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The GET /repos/{owner}/{repo}/branches endpoint currently has no way to filter branches by name server-side, forcing API consumers to paginate through all branches and filter client-side.
The UI already supports branch search (added in #27055). The underlying DB layer has a Keyword field on FindBranchOptions in models/git/branch_list.go that does a LIKE %keyword% SQL filter, it just wasn't wired up to the API handler.
This PR exposes a ?q= query parameter on the endpoint that maps to FindBranchOptions.Keyword.
Example:
GET /repos/owner/repo/branches?q=featureCloses #37981