@@ -241,10 +241,22 @@ func CreatePullRequest(ctx *context.APIContext, form api.CreatePullRequestOption
241
241
return
242
242
}
243
243
244
- labelIDs = make ([]int64 , len (labels ))
244
+ labelIDs = make ([]int64 , len (form . Labels ))
245
245
for i := range labels {
246
246
labelIDs [i ] = labels [i ].ID
247
247
}
248
+
249
+ if ctx .Repo .Owner .IsOrganization () {
250
+ labels , err = models .GetLabelsInOrgByIDs (ctx .Repo .Owner .ID , form .Labels )
251
+ if err != nil {
252
+ ctx .Error (http .StatusInternalServerError , "GetLabelsInOrgByIDs" , err )
253
+ return
254
+ }
255
+
256
+ for i := range labels {
257
+ labelIDs [i ] = labels [i ].ID
258
+ }
259
+ }
248
260
}
249
261
250
262
if form .Milestone > 0 {
@@ -456,6 +468,18 @@ func EditPullRequest(ctx *context.APIContext, form api.EditPullRequestOption) {
456
468
ctx .Error (http .StatusInternalServerError , "ReplaceLabelsError" , err )
457
469
return
458
470
}
471
+
472
+ if ctx .Repo .Owner .IsOrganization () {
473
+ labels , err = models .GetLabelsInOrgByIDs (ctx .Repo .Owner .ID , form .Labels )
474
+ if err != nil {
475
+ ctx .Error (http .StatusInternalServerError , "GetLabelsInOrgByIDs" , err )
476
+ return
477
+ }
478
+ if err = issue .ReplaceLabels (labels , ctx .User ); err != nil {
479
+ ctx .Error (http .StatusInternalServerError , "ReplaceLabelsError" , err )
480
+ return
481
+ }
482
+ }
459
483
}
460
484
461
485
if err = models .UpdateIssueByAPI (issue ); err != nil {
0 commit comments