@@ -176,6 +176,8 @@ func CreateTag(ctx *context.APIContext) {
176176 // "$ref": "#/responses/Tag"
177177 // "404":
178178 // "$ref": "#/responses/notFound"
179+ // "405":
180+ // "$ref": "#/responses/empty"
179181 // "409":
180182 // "$ref": "#/responses/conflict"
181183 form := web .GetForm (ctx ).(* api.CreateTagOption )
@@ -196,6 +198,11 @@ func CreateTag(ctx *context.APIContext) {
196198 ctx .Error (http .StatusConflict , "tag exist" , err )
197199 return
198200 }
201+ if models .IsErrProtectedTagName (err ) {
202+ ctx .Error (http .StatusMethodNotAllowed , "CreateNewTag" , "user not allowed to create protected tag" )
203+ return
204+ }
205+
199206 ctx .InternalServerError (err )
200207 return
201208 }
@@ -236,6 +243,8 @@ func DeleteTag(ctx *context.APIContext) {
236243 // "$ref": "#/responses/empty"
237244 // "404":
238245 // "$ref": "#/responses/notFound"
246+ // "405":
247+ // "$ref": "#/responses/empty"
239248 // "409":
240249 // "$ref": "#/responses/conflict"
241250 tagName := ctx .Params ("*" )
@@ -256,7 +265,12 @@ func DeleteTag(ctx *context.APIContext) {
256265 }
257266
258267 if err = releaseservice .DeleteReleaseByID (ctx , tag .ID , ctx .Doer , true ); err != nil {
268+ if models .IsErrProtectedTagName (err ) {
269+ ctx .Error (http .StatusMethodNotAllowed , "delTag" , "user not allowed to delete protected tag" )
270+ return
271+ }
259272 ctx .Error (http .StatusInternalServerError , "DeleteReleaseByID" , err )
273+ return
260274 }
261275
262276 ctx .Status (http .StatusNoContent )
0 commit comments