Return 409 when creating repo if it already exists. (#6330)

This commit is contained in:
Bogdan Petrea 2019-03-15 14:19:09 +00:00 committed by techknowlogick
parent 7780ea8890
commit 583968f274
2 changed files with 74 additions and 2 deletions

View file

@ -226,8 +226,9 @@ func CreateUserRepo(ctx *context.APIContext, owner *models.User, opt api.CreateR
AutoInit: opt.AutoInit,
})
if err != nil {
if models.IsErrRepoAlreadyExist(err) ||
models.IsErrNameReserved(err) ||
if models.IsErrRepoAlreadyExist(err) {
ctx.Error(409, "", "The repository with the same name already exists.")
} else if models.IsErrNameReserved(err) ||
models.IsErrNamePatternNotAllowed(err) {
ctx.Error(422, "", err)
} else {