diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2024-04-12 18:11:16 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-12 13:11:16 +0300 |
commit | 9466fec879f4f2c88c7c1e7a5cffba319282ab66 (patch) | |
tree | b51fbda349aea5a39afe4c1286556dc4313cb135 /routers | |
parent | f9fdac9809335729b2ac3227b2a5f71a62fc64ad (diff) | |
download | gitea-9466fec879f4f2c88c7c1e7a5cffba319282ab66.tar.gz gitea-9466fec879f4f2c88c7c1e7a5cffba319282ab66.zip |
Fix rename branch 500 when the target branch is deleted but exist in database (#30430)
Fix #30428
Diffstat (limited to 'routers')
-rw-r--r-- | routers/web/repo/setting/protected_branch.go | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/routers/web/repo/setting/protected_branch.go b/routers/web/repo/setting/protected_branch.go index b30dc3b061..4bab3f897a 100644 --- a/routers/web/repo/setting/protected_branch.go +++ b/routers/web/repo/setting/protected_branch.go @@ -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 } |