@@ -215,6 +215,9 @@ func CreateRelease(ctx *context.APIContext) {
215215 // "$ref": "#/responses/notFound"
216216 // "409":
217217 // "$ref": "#/responses/error"
218+ // "422":
219+ // "$ref": "#/responses/validationError"
220+
218221 form := web .GetForm (ctx ).(* api.CreateReleaseOption )
219222 if ctx .Repo .Repository .IsEmpty {
220223 ctx .Error (http .StatusUnprocessableEntity , "RepoIsEmpty" , fmt .Errorf ("repo is empty" ))
@@ -246,6 +249,8 @@ func CreateRelease(ctx *context.APIContext) {
246249 if err := release_service .CreateRelease (ctx .Repo .GitRepo , rel , nil , "" ); err != nil {
247250 if repo_model .IsErrReleaseAlreadyExist (err ) {
248251 ctx .Error (http .StatusConflict , "ReleaseAlreadyExist" , err )
252+ } else if models .IsErrProtectedTagName (err ) {
253+ ctx .Error (http .StatusUnprocessableEntity , "ProtectedTagName" , err )
249254 } else {
250255 ctx .Error (http .StatusInternalServerError , "CreateRelease" , err )
251256 }
@@ -386,8 +391,8 @@ func DeleteRelease(ctx *context.APIContext) {
386391 // "$ref": "#/responses/empty"
387392 // "404":
388393 // "$ref": "#/responses/notFound"
389- // "405 ":
390- // "$ref": "#/responses/empty "
394+ // "422 ":
395+ // "$ref": "#/responses/validationError "
391396
392397 id := ctx .ParamsInt64 (":id" )
393398 rel , err := repo_model .GetReleaseForRepoByID (ctx , ctx .Repo .Repository .ID , id )
@@ -401,7 +406,7 @@ func DeleteRelease(ctx *context.APIContext) {
401406 }
402407 if err := release_service .DeleteReleaseByID (ctx , ctx .Repo .Repository , rel , ctx .Doer , false ); err != nil {
403408 if models .IsErrProtectedTagName (err ) {
404- ctx .Error (http .StatusMethodNotAllowed , "delTag" , "user not allowed to delete protected tag" )
409+ ctx .Error (http .StatusUnprocessableEntity , "delTag" , "user not allowed to delete protected tag" )
405410 return
406411 }
407412 ctx .Error (http .StatusInternalServerError , "DeleteReleaseByID" , err )
0 commit comments