diff options
author | Lunny Xiao | 2019-02-27 11:32:25 +0800 |
---|---|---|
committer | techknowlogick | 2019-02-26 22:32:25 -0500 |
commit | cbfc7f52b96e2b6fa9c356801a616a319ad3638e (patch) | |
tree | e676e61ada3b624f1b4897dd171b6c0514359b8c | |
parent | d602ba564f3b5e00f38232410e7653c993edc500 (diff) |
fix bug when migrate repository 500 when repo is existed (#6188) (#6197)
-rw-r--r-- | routers/api/v1/repo/repo.go | 5 | ||||
-rw-r--r-- | routers/repo/repo.go | 5 |
2 files changed, 10 insertions, 0 deletions
diff --git a/routers/api/v1/repo/repo.go b/routers/api/v1/repo/repo.go index d78700c6b..147e7d23f 100644 --- a/routers/api/v1/repo/repo.go +++ b/routers/api/v1/repo/repo.go @@ -400,6 +400,11 @@ func Migrate(ctx *context.APIContext, form auth.MigrateRepoForm) { RemoteAddr: remoteAddr, }) if err != nil { + if models.IsErrRepoAlreadyExist(err) { + ctx.Error(409, "", "The repository with the same name already exists.") + return + } + err = util.URLSanitizedError(err, remoteAddr) if repo != nil { if errDelete := models.DeleteRepository(ctx.User, ctxUser.ID, repo.ID); errDelete != nil { diff --git a/routers/repo/repo.go b/routers/repo/repo.go index 236d66bd1..ba0c860e6 100644 --- a/routers/repo/repo.go +++ b/routers/repo/repo.go @@ -256,6 +256,11 @@ func MigratePost(ctx *context.Context, form auth.MigrateRepoForm) { return } + if models.IsErrRepoAlreadyExist(err) { + ctx.RenderWithErr(ctx.Tr("form.repo_name_been_taken"), tplMigrate, &form) + return + } + // remoteAddr may contain credentials, so we sanitize it err = util.URLSanitizedError(err, remoteAddr) |