]> source.dussan.org Git - gitea.git/commitdiff
added the ability to set labels on the "edit pull request" api (#5347)
authorLucien Kerl <lucien@kerl.io>
Fri, 16 Nov 2018 11:12:44 +0000 (12:12 +0100)
committerJonas Franz <info@jonasfranz.software>
Fri, 16 Nov 2018 11:12:44 +0000 (12:12 +0100)
Signed-off-by: Lucien Kerl <lucien.kerl@wuerth-it.com>
routers/api/v1/repo/pull.go

index 5ce6f868bcd09febbd6b694a258d930bca52512b..83ef886d7d319dfef0fe6731e5cb19b7e337cc50 100644 (file)
@@ -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