Skip to content

allow filtering /repos/{owner}/{repo}/pulls by target base branch queryparam #33684

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 27, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions models/issues/pull_list.go
Original file line number Diff line number Diff line change
@@ -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":
5 changes: 5 additions & 0 deletions routers/api/v1/repo/pull.go
Original file line number Diff line number Diff line change
@@ -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)
6 changes: 6 additions & 0 deletions templates/swagger/v1_json.tmpl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.