summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--routers/api/v1/repo/repo.go5
-rw-r--r--routers/repo/repo.go5
2 files changed, 10 insertions, 0 deletions
diff --git a/routers/api/v1/repo/repo.go b/routers/api/v1/repo/repo.go
index 4156775286..c6a7803acb 100644
--- a/routers/api/v1/repo/repo.go
+++ b/routers/api/v1/repo/repo.go
@@ -408,6 +408,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 960961a5e5..42dfd56268 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)