Skip to content

Commit

Permalink
added the ability to set labels on the "edit pull request" api (#5347)
Browse files Browse the repository at this point in the history
Signed-off-by: Lucien Kerl <lucien.kerl@wuerth-it.com>
  • Loading branch information
lucienkerl authored and jonasfranz committed Nov 16, 2018
1 parent 7278372 commit 89eea64
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions routers/api/v1/repo/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,18 @@ func EditPullRequest(ctx *context.APIContext, form api.EditPullRequestOption) {
}
}

if ctx.Repo.IsWriter() && (form.Labels != nil && len(form.Labels) > 0) {
labels, err := models.GetLabelsInRepoByIDs(ctx.Repo.Repository.ID, form.Labels)
if err != nil {
ctx.Error(500, "GetLabelsInRepoByIDsError", err)
return
}
if err = issue.ReplaceLabels(labels, ctx.User); err != nil {
ctx.Error(500, "ReplaceLabelsError", err)
return
}
}

if err = models.UpdateIssue(issue); err != nil {
ctx.Error(500, "UpdateIssue", err)
return
Expand Down

0 comments on commit 89eea64

Please sign in to comment.