@@ -176,6 +176,8 @@ func CreateTag(ctx *context.APIContext) {
176
176
// "$ref": "#/responses/Tag"
177
177
// "404":
178
178
// "$ref": "#/responses/notFound"
179
+ // "405":
180
+ // "$ref": "#/responses/empty"
179
181
// "409":
180
182
// "$ref": "#/responses/conflict"
181
183
form := web .GetForm (ctx ).(* api.CreateTagOption )
@@ -196,6 +198,11 @@ func CreateTag(ctx *context.APIContext) {
196
198
ctx .Error (http .StatusConflict , "tag exist" , err )
197
199
return
198
200
}
201
+ if models .IsErrProtectedTagName (err ) {
202
+ ctx .Error (http .StatusMethodNotAllowed , "CreateNewTag" , "user not allowed to create protected tag" )
203
+ return
204
+ }
205
+
199
206
ctx .InternalServerError (err )
200
207
return
201
208
}
@@ -236,6 +243,8 @@ func DeleteTag(ctx *context.APIContext) {
236
243
// "$ref": "#/responses/empty"
237
244
// "404":
238
245
// "$ref": "#/responses/notFound"
246
+ // "405":
247
+ // "$ref": "#/responses/empty"
239
248
// "409":
240
249
// "$ref": "#/responses/conflict"
241
250
tagName := ctx .Params ("*" )
@@ -256,7 +265,12 @@ func DeleteTag(ctx *context.APIContext) {
256
265
}
257
266
258
267
if err = releaseservice .DeleteReleaseByID (tag .ID , ctx .User , true ); err != nil {
268
+ if models .IsErrProtectedTagName (err ) {
269
+ ctx .Error (http .StatusMethodNotAllowed , "delTag" , "user not allowed to delete protected tag" )
270
+ return
271
+ }
259
272
ctx .Error (http .StatusInternalServerError , "DeleteReleaseByID" , err )
273
+ return
260
274
}
261
275
262
276
ctx .Status (http .StatusNoContent )
0 commit comments