|
|
@ -52,56 +52,79 @@ func ListPullRequests(ctx *context.APIContext) { |
|
|
|
// parameters:
|
|
|
|
// parameters:
|
|
|
|
// - name: owner
|
|
|
|
// - name: owner
|
|
|
|
// in: path
|
|
|
|
// in: path
|
|
|
|
// description: owner of the repo
|
|
|
|
// description: Owner of the repo
|
|
|
|
// type: string
|
|
|
|
// type: string
|
|
|
|
// required: true
|
|
|
|
// required: true
|
|
|
|
// - name: repo
|
|
|
|
// - name: repo
|
|
|
|
// in: path
|
|
|
|
// in: path
|
|
|
|
// description: name of the repo
|
|
|
|
// description: Name of the repo
|
|
|
|
// type: string
|
|
|
|
// type: string
|
|
|
|
// required: true
|
|
|
|
// required: true
|
|
|
|
// - name: state
|
|
|
|
// - name: state
|
|
|
|
// in: query
|
|
|
|
// in: query
|
|
|
|
// description: "State of pull request: open or closed (optional)"
|
|
|
|
// description: State of pull request
|
|
|
|
// type: string
|
|
|
|
// type: string
|
|
|
|
// enum: [closed, open, all]
|
|
|
|
// enum: [open, closed, all]
|
|
|
|
|
|
|
|
// default: open
|
|
|
|
// - name: sort
|
|
|
|
// - name: sort
|
|
|
|
// in: query
|
|
|
|
// in: query
|
|
|
|
// description: "Type of sort"
|
|
|
|
// description: Type of sort
|
|
|
|
// type: string
|
|
|
|
// type: string
|
|
|
|
// enum: [oldest, recentupdate, leastupdate, mostcomment, leastcomment, priority]
|
|
|
|
// enum: [oldest, recentupdate, leastupdate, mostcomment, leastcomment, priority]
|
|
|
|
// - name: milestone
|
|
|
|
// - name: milestone
|
|
|
|
// in: query
|
|
|
|
// in: query
|
|
|
|
// description: "ID of the milestone"
|
|
|
|
// description: ID of the milestone
|
|
|
|
// type: integer
|
|
|
|
// type: integer
|
|
|
|
// format: int64
|
|
|
|
// format: int64
|
|
|
|
// - name: labels
|
|
|
|
// - name: labels
|
|
|
|
// in: query
|
|
|
|
// in: query
|
|
|
|
// description: "Label IDs"
|
|
|
|
// description: Label IDs
|
|
|
|
// type: array
|
|
|
|
// type: array
|
|
|
|
// collectionFormat: multi
|
|
|
|
// collectionFormat: multi
|
|
|
|
// items:
|
|
|
|
// items:
|
|
|
|
// type: integer
|
|
|
|
// type: integer
|
|
|
|
// format: int64
|
|
|
|
// format: int64
|
|
|
|
|
|
|
|
// - name: poster
|
|
|
|
|
|
|
|
// in: query
|
|
|
|
|
|
|
|
// description: Filter by pull request author
|
|
|
|
|
|
|
|
// type: string
|
|
|
|
// - name: page
|
|
|
|
// - name: page
|
|
|
|
// in: query
|
|
|
|
// in: query
|
|
|
|
// description: page number of results to return (1-based)
|
|
|
|
// description: Page number of results to return (1-based)
|
|
|
|
// type: integer
|
|
|
|
// type: integer
|
|
|
|
|
|
|
|
// minimum: 1
|
|
|
|
|
|
|
|
// default: 1
|
|
|
|
// - name: limit
|
|
|
|
// - name: limit
|
|
|
|
// in: query
|
|
|
|
// in: query
|
|
|
|
// description: page size of results
|
|
|
|
// description: Page size of results
|
|
|
|
// type: integer
|
|
|
|
// type: integer
|
|
|
|
|
|
|
|
// minimum: 0
|
|
|
|
// responses:
|
|
|
|
// responses:
|
|
|
|
// "200":
|
|
|
|
// "200":
|
|
|
|
// "$ref": "#/responses/PullRequestList"
|
|
|
|
// "$ref": "#/responses/PullRequestList"
|
|
|
|
// "404":
|
|
|
|
// "404":
|
|
|
|
// "$ref": "#/responses/notFound"
|
|
|
|
// "$ref": "#/responses/notFound"
|
|
|
|
|
|
|
|
// "500":
|
|
|
|
|
|
|
|
// "$ref": "#/responses/error"
|
|
|
|
|
|
|
|
|
|
|
|
labelIDs, err := base.StringsToInt64s(ctx.FormStrings("labels")) |
|
|
|
labelIDs, err := base.StringsToInt64s(ctx.FormStrings("labels")) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
ctx.Error(http.StatusInternalServerError, "PullRequests", err) |
|
|
|
ctx.Error(http.StatusInternalServerError, "PullRequests", err) |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
var posterID int64 |
|
|
|
|
|
|
|
if posterStr := ctx.FormString("poster"); posterStr != "" { |
|
|
|
|
|
|
|
poster, err := user_model.GetUserByName(ctx, posterStr) |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
if user_model.IsErrUserNotExist(err) { |
|
|
|
|
|
|
|
ctx.Error(http.StatusBadRequest, "Poster not found", err) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
ctx.Error(http.StatusInternalServerError, "GetUserByName", err) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
posterID = poster.ID |
|
|
|
|
|
|
|
} |
|
|
|
listOptions := utils.GetListOptions(ctx) |
|
|
|
listOptions := utils.GetListOptions(ctx) |
|
|
|
prs, maxResults, err := issues_model.PullRequests(ctx, ctx.Repo.Repository.ID, &issues_model.PullRequestsOptions{ |
|
|
|
prs, maxResults, err := issues_model.PullRequests(ctx, ctx.Repo.Repository.ID, &issues_model.PullRequestsOptions{ |
|
|
|
ListOptions: listOptions, |
|
|
|
ListOptions: listOptions, |
|
|
@ -109,6 +132,7 @@ func ListPullRequests(ctx *context.APIContext) { |
|
|
|
SortType: ctx.FormTrim("sort"), |
|
|
|
SortType: ctx.FormTrim("sort"), |
|
|
|
Labels: labelIDs, |
|
|
|
Labels: labelIDs, |
|
|
|
MilestoneID: ctx.FormInt64("milestone"), |
|
|
|
MilestoneID: ctx.FormInt64("milestone"), |
|
|
|
|
|
|
|
PosterID: posterID, |
|
|
|
}) |
|
|
|
}) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
ctx.Error(http.StatusInternalServerError, "PullRequests", err) |
|
|
|
ctx.Error(http.StatusInternalServerError, "PullRequests", err) |
|
|
|