Skip to content

Commit fd310d5

Browse files
author
Royce Remer
committed
allow filtering /repos/{owner}/{repo}/pulls by target base branch queryparam
1 parent a25081f commit fd310d5

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

models/issues/pull_list.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,16 @@ type PullRequestsOptions struct {
2828
Labels []int64
2929
MilestoneID int64
3030
PosterID int64
31+
BaseBranch string
3132
}
3233

3334
func listPullRequestStatement(ctx context.Context, baseRepoID int64, opts *PullRequestsOptions) *xorm.Session {
3435
sess := db.GetEngine(ctx).Where("pull_request.base_repo_id=?", baseRepoID)
3536

37+
if len(opts.BaseBranch) > 0 {
38+
sess.And("pull_request.base_branch=?", opts.BaseBranch)
39+
}
40+
3641
sess.Join("INNER", "issue", "pull_request.issue_id = issue.id")
3742
switch opts.State {
3843
case "closed", "open":

routers/api/v1/repo/pull.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ func ListPullRequests(ctx *context.APIContext) {
5959
// description: Name of the repo
6060
// type: string
6161
// required: true
62+
// - name: base_branch
63+
// in: query
64+
// description: Filter by target base branch of the pull request
65+
// type: string
6266
// - name: state
6367
// in: query
6468
// description: State of pull request
@@ -132,6 +136,7 @@ func ListPullRequests(ctx *context.APIContext) {
132136
Labels: labelIDs,
133137
MilestoneID: ctx.FormInt64("milestone"),
134138
PosterID: posterID,
139+
BaseBranch: ctx.FormTrim("base_branch"),
135140
})
136141
if err != nil {
137142
ctx.APIErrorInternal(err)

0 commit comments

Comments
 (0)