aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoyce Remer <royceremer@gmail.com>2025-02-27 09:50:44 -0800
committerGitHub <noreply@github.com>2025-02-27 17:50:44 +0000
commitb7aac5ef9a8bb86a5b62cb4e0d15d6034308cc5c (patch)
treebafd4610c9f757693e80452470aabda239da58ee
parent01156f9cc48d67e00657a788249ac02a6ed733cd (diff)
downloadgitea-b7aac5ef9a8bb86a5b62cb4e0d15d6034308cc5c.tar.gz
gitea-b7aac5ef9a8bb86a5b62cb4e0d15d6034308cc5c.zip
allow filtering /repos/{owner}/{repo}/pulls by target base branch queryparam (#33684)
Co-authored-by: Royce Remer <rremer@salesforce.com> Co-authored-by: delvh <dev.lh@web.de>
-rw-r--r--models/issues/pull_list.go5
-rw-r--r--routers/api/v1/repo/pull.go5
-rw-r--r--templates/swagger/v1_json.tmpl6
3 files changed, 16 insertions, 0 deletions
diff --git a/models/issues/pull_list.go b/models/issues/pull_list.go
index 1ddb94e566..b105fab97c 100644
--- a/models/issues/pull_list.go
+++ b/models/issues/pull_list.go
@@ -28,11 +28,16 @@ type PullRequestsOptions struct {
Labels []int64
MilestoneID int64
PosterID int64
+ BaseBranch string
}
func listPullRequestStatement(ctx context.Context, baseRepoID int64, opts *PullRequestsOptions) *xorm.Session {
sess := db.GetEngine(ctx).Where("pull_request.base_repo_id=?", baseRepoID)
+ if opts.BaseBranch != "" {
+ sess.And("pull_request.base_branch=?", opts.BaseBranch)
+ }
+
sess.Join("INNER", "issue", "pull_request.issue_id = issue.id")
switch opts.State {
case "closed", "open":
diff --git a/routers/api/v1/repo/pull.go b/routers/api/v1/repo/pull.go
index 1f61ac031a..412f2cfb58 100644
--- a/routers/api/v1/repo/pull.go
+++ b/routers/api/v1/repo/pull.go
@@ -59,6 +59,10 @@ func ListPullRequests(ctx *context.APIContext) {
// description: Name of the repo
// type: string
// required: true
+ // - name: base_branch
+ // in: query
+ // description: Filter by target base branch of the pull request
+ // type: string
// - name: state
// in: query
// description: State of pull request
@@ -132,6 +136,7 @@ func ListPullRequests(ctx *context.APIContext) {
Labels: labelIDs,
MilestoneID: ctx.FormInt64("milestone"),
PosterID: posterID,
+ BaseBranch: ctx.FormTrim("base_branch"),
})
if err != nil {
ctx.APIErrorInternal(err)
diff --git a/templates/swagger/v1_json.tmpl b/templates/swagger/v1_json.tmpl
index fd3e2a70f1..48ed958ca2 100644
--- a/templates/swagger/v1_json.tmpl
+++ b/templates/swagger/v1_json.tmpl
@@ -12048,6 +12048,12 @@
"required": true
},
{
+ "type": "string",
+ "description": "Filter by target base branch of the pull request",
+ "name": "base_branch",
+ "in": "query"
+ },
+ {
"enum": [
"open",
"closed",