Skip to content

Commit cbfc7f5

Browse files
lunnytechknowlogick
authored andcommitted
fix bug when migrate repository 500 when repo is existed (#6188) (#6197)
1 parent d602ba5 commit cbfc7f5

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

routers/api/v1/repo/repo.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,11 @@ func Migrate(ctx *context.APIContext, form auth.MigrateRepoForm) {
400400
RemoteAddr: remoteAddr,
401401
})
402402
if err != nil {
403+
if models.IsErrRepoAlreadyExist(err) {
404+
ctx.Error(409, "", "The repository with the same name already exists.")
405+
return
406+
}
407+
403408
err = util.URLSanitizedError(err, remoteAddr)
404409
if repo != nil {
405410
if errDelete := models.DeleteRepository(ctx.User, ctxUser.ID, repo.ID); errDelete != nil {

routers/repo/repo.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,11 @@ func MigratePost(ctx *context.Context, form auth.MigrateRepoForm) {
256256
return
257257
}
258258

259+
if models.IsErrRepoAlreadyExist(err) {
260+
ctx.RenderWithErr(ctx.Tr("form.repo_name_been_taken"), tplMigrate, &form)
261+
return
262+
}
263+
259264
// remoteAddr may contain credentials, so we sanitize it
260265
err = util.URLSanitizedError(err, remoteAddr)
261266

0 commit comments

Comments
 (0)