Skip to content

feat(api): add q parameter to list branches API for server-side filtering - #37982

Merged
lunny merged 10 commits into
go-gitea:mainfrom
HarshMN2345:feat/branches-api-search
Jun 3, 2026
Merged

lunny merged 10 commits into
go-gitea:mainfrom
HarshMN2345:feat/branches-api-search

Conversation

@HarshMN2345

Copy link
Copy Markdown
Contributor

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=feature
Closes #37981

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jun 3, 2026
@github-actions github-actions Bot added the type/feature Completely new functionality. Can only be merged if feature freeze is not active. label Jun 3, 2026
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Jun 3, 2026
@lunny lunny added type/enhancement An improvement of existing functionality and removed type/feature Completely new functionality. Can only be merged if feature freeze is not active. labels Jun 3, 2026
@lunny lunny added this to the 1.27.0 milestone Jun 3, 2026
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Jun 3, 2026
Comment thread tests/integration/api_repo_branch_test.go Outdated
@wxiaoguang
wxiaoguang marked this pull request as draft June 3, 2026 06:46
@HarshMN2345
HarshMN2345 force-pushed the feat/branches-api-search branch from adc937b to 0458a8e Compare June 3, 2026 07:09
@wxiaoguang

Copy link
Copy Markdown
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
wxiaoguang marked this pull request as ready for review June 3, 2026 07:14
@github-actions github-actions Bot added type/feature Completely new functionality. Can only be merged if feature freeze is not active. and removed type/enhancement An improvement of existing functionality labels Jun 3, 2026
@bircni

bircni commented Jun 3, 2026

Copy link
Copy Markdown
Member

Is it really a FEATURE

@lunny lunny added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Jun 3, 2026
@lunny
lunny merged commit 792fa5e into go-gitea:main Jun 3, 2026
23 checks passed
@GiteaBot GiteaBot removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Jun 3, 2026
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>
@go-gitea go-gitea locked as resolved and limited conversation to collaborators Sep 2, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/feature Completely new functionality. Can only be merged if feature freeze is not active.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

expose branch search via q parameter on GET /repos/{owner}/{repo}/branches

6 participants