mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-11-04 05:25:15 +01:00 
			
		
		
		
	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>
This commit is contained in:
		
							parent
							
								
									01156f9cc4
								
							
						
					
					
						commit
						b7aac5ef9a
					
				@ -28,11 +28,16 @@ type PullRequestsOptions struct {
 | 
				
			|||||||
	Labels      []int64
 | 
						Labels      []int64
 | 
				
			||||||
	MilestoneID int64
 | 
						MilestoneID int64
 | 
				
			||||||
	PosterID    int64
 | 
						PosterID    int64
 | 
				
			||||||
 | 
						BaseBranch  string
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func listPullRequestStatement(ctx context.Context, baseRepoID int64, opts *PullRequestsOptions) *xorm.Session {
 | 
					func listPullRequestStatement(ctx context.Context, baseRepoID int64, opts *PullRequestsOptions) *xorm.Session {
 | 
				
			||||||
	sess := db.GetEngine(ctx).Where("pull_request.base_repo_id=?", baseRepoID)
 | 
						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")
 | 
						sess.Join("INNER", "issue", "pull_request.issue_id = issue.id")
 | 
				
			||||||
	switch opts.State {
 | 
						switch opts.State {
 | 
				
			||||||
	case "closed", "open":
 | 
						case "closed", "open":
 | 
				
			||||||
 | 
				
			|||||||
@ -59,6 +59,10 @@ func ListPullRequests(ctx *context.APIContext) {
 | 
				
			|||||||
	//   description: Name of the repo
 | 
						//   description: Name of the repo
 | 
				
			||||||
	//   type: string
 | 
						//   type: string
 | 
				
			||||||
	//   required: true
 | 
						//   required: true
 | 
				
			||||||
 | 
						// - name: base_branch
 | 
				
			||||||
 | 
						//   in: query
 | 
				
			||||||
 | 
						//   description: Filter by target base branch of the pull request
 | 
				
			||||||
 | 
						//   type: string
 | 
				
			||||||
	// - name: state
 | 
						// - name: state
 | 
				
			||||||
	//   in: query
 | 
						//   in: query
 | 
				
			||||||
	//   description: State of pull request
 | 
						//   description: State of pull request
 | 
				
			||||||
@ -132,6 +136,7 @@ func ListPullRequests(ctx *context.APIContext) {
 | 
				
			|||||||
		Labels:      labelIDs,
 | 
							Labels:      labelIDs,
 | 
				
			||||||
		MilestoneID: ctx.FormInt64("milestone"),
 | 
							MilestoneID: ctx.FormInt64("milestone"),
 | 
				
			||||||
		PosterID:    posterID,
 | 
							PosterID:    posterID,
 | 
				
			||||||
 | 
							BaseBranch:  ctx.FormTrim("base_branch"),
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		ctx.APIErrorInternal(err)
 | 
							ctx.APIErrorInternal(err)
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										6
									
								
								templates/swagger/v1_json.tmpl
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										6
									
								
								templates/swagger/v1_json.tmpl
									
									
									
										generated
									
									
									
								
							@ -12047,6 +12047,12 @@
 | 
				
			|||||||
            "in": "path",
 | 
					            "in": "path",
 | 
				
			||||||
            "required": true
 | 
					            "required": true
 | 
				
			||||||
          },
 | 
					          },
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
 | 
					            "type": "string",
 | 
				
			||||||
 | 
					            "description": "Filter by target base branch of the pull request",
 | 
				
			||||||
 | 
					            "name": "base_branch",
 | 
				
			||||||
 | 
					            "in": "query"
 | 
				
			||||||
 | 
					          },
 | 
				
			||||||
          {
 | 
					          {
 | 
				
			||||||
            "enum": [
 | 
					            "enum": [
 | 
				
			||||||
              "open",
 | 
					              "open",
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user