1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-03 09:07:19 +00:00

Fix rename branch 500 when the target branch is deleted but exist in database (#30430)

Fix #30428
This commit is contained in:
Lunny Xiao
2024-04-12 18:11:16 +08:00
committed by GitHub
parent f9fdac9809
commit 9466fec879
3 changed files with 107 additions and 12 deletions

View File

@ -313,7 +313,13 @@ func RenameBranchPost(ctx *context.Context) {
msg, err := repository.RenameBranch(ctx, ctx.Repo.Repository, ctx.Doer, ctx.Repo.GitRepo, form.From, form.To)
if err != nil {
ctx.ServerError("RenameBranch", err)
switch {
case git_model.IsErrBranchAlreadyExists(err):
ctx.Flash.Error(ctx.Tr("repo.branch.branch_already_exists", form.To))
ctx.Redirect(fmt.Sprintf("%s/branches", ctx.Repo.RepoLink))
default:
ctx.ServerError("RenameBranch", err)
}
return
}