@@ -241,10 +241,26 @@ 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
+ orgLabelIDs := make ([]int64 , len (form .Labels ))
246
+
245
247
for i := range labels {
246
248
labelIDs [i ] = labels [i ].ID
247
249
}
250
+
251
+ if ctx .Repo .Owner .IsOrganization () {
252
+ orgLabels , err := models .GetLabelsInOrgByIDs (ctx .Repo .Owner .ID , form .Labels )
253
+ if err != nil {
254
+ ctx .Error (http .StatusInternalServerError , "GetLabelsInOrgByIDs" , err )
255
+ return
256
+ }
257
+
258
+ for i := range orgLabels {
259
+ orgLabelIDs [i ] = orgLabels [i ].ID
260
+ }
261
+ }
262
+
263
+ labelIDs = append (labelIDs , orgLabelIDs ... )
248
264
}
249
265
250
266
if form .Milestone > 0 {
@@ -452,6 +468,17 @@ func EditPullRequest(ctx *context.APIContext, form api.EditPullRequestOption) {
452
468
ctx .Error (http .StatusInternalServerError , "GetLabelsInRepoByIDsError" , err )
453
469
return
454
470
}
471
+
472
+ if ctx .Repo .Owner .IsOrganization () {
473
+ orgLabels , err := models .GetLabelsInOrgByIDs (ctx .Repo .Owner .ID , form .Labels )
474
+ if err != nil {
475
+ ctx .Error (http .StatusInternalServerError , "GetLabelsInOrgByIDs" , err )
476
+ return
477
+ }
478
+
479
+ labels = append (labels , orgLabels ... )
480
+ }
481
+
455
482
if err = issue .ReplaceLabels (labels , ctx .User ); err != nil {
456
483
ctx .Error (http .StatusInternalServerError , "ReplaceLabelsError" , err )
457
484
return
0 commit comments