Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix bug when migrate repository 500 when repo is existed #6188

Merged
merged 3 commits into from Feb 26, 2019
Merged
Changes from 2 commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -560,6 +560,7 @@ migrate.clone_local_path = or a local server path
migrate.permission_denied = You are not allowed to import local repositories.
migrate.invalid_local_path = "The local path is invalid. It does not exist or is not a directory."
migrate.failed = Migration failed: %v
migrate.repo_existed = The repository with the same name has existed.
migrate.lfs_mirror_unsupported = Mirroring LFS objects is not supported - use 'git lfs fetch --all' and 'git lfs push --all' instead.
mirror_from = mirror of
@@ -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 has existed.")
This conversation was marked as resolved by lafriks

This comment has been minimized.

Copy link
@lafriks

lafriks Feb 26, 2019

Member
Suggested change
ctx.Error(409, "", "The repository with the same name has existed.")
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 {
@@ -256,6 +256,11 @@ func MigratePost(ctx *context.Context, form auth.MigrateRepoForm) {
return
}

if models.IsErrRepoAlreadyExist(err) {
ctx.RenderWithErr(ctx.Tr("repo.migrate.repo_existed"), tplMigrate, &form)
This conversation was marked as resolved by lafriks

This comment has been minimized.

Copy link
@lafriks

lafriks Feb 26, 2019

Member

Why not use already existing error message?

Suggested change
ctx.RenderWithErr(ctx.Tr("repo.migrate.repo_existed"), tplMigrate, &form)
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)

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.