aboutsummaryrefslogtreecommitdiffstats
path: root/routers/web/repo/pull.go
diff options
context:
space:
mode:
authoryp05327 <576951401@qq.com>2023-05-22 19:21:46 +0900
committerGitHub <noreply@github.com>2023-05-22 18:21:46 +0800
commitbebc3433c5c1e843ac36603eafd1a0615f64716f (patch)
tree676788ccea930dc271c47de9de3b0632704c2c73 /routers/web/repo/pull.go
parentf4ef7eed0072d037c3a211af36ccc9f4e11d0014 (diff)
downloadgitea-bebc3433c5c1e843ac36603eafd1a0615f64716f.tar.gz
gitea-bebc3433c5c1e843ac36603eafd1a0615f64716f.zip
Add IsErrRepoFilesAlreadyExist check when fork repo (#24678)
Before: ![image](https://github.com/go-gitea/gitea/assets/18380374/e9e3de75-eb6e-418e-9227-ef4e5f448a04) After: ![image](https://github.com/go-gitea/gitea/assets/18380374/74b1cd6c-c5b1-4ee0-a1d8-6b3fb8d3a8e9)
Diffstat (limited to 'routers/web/repo/pull.go')
-rw-r--r--routers/web/repo/pull.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/routers/web/repo/pull.go b/routers/web/repo/pull.go
index 8821e74c95..09dbc23eac 100644
--- a/routers/web/repo/pull.go
+++ b/routers/web/repo/pull.go
@@ -272,6 +272,17 @@ func ForkPost(ctx *context.Context) {
ctx.RenderWithErr(msg, tplFork, &form)
case repo_model.IsErrRepoAlreadyExist(err):
ctx.RenderWithErr(ctx.Tr("repo.settings.new_owner_has_same_repo"), tplFork, &form)
+ case repo_model.IsErrRepoFilesAlreadyExist(err):
+ switch {
+ case ctx.IsUserSiteAdmin() || (setting.Repository.AllowAdoptionOfUnadoptedRepositories && setting.Repository.AllowDeleteOfUnadoptedRepositories):
+ ctx.RenderWithErr(ctx.Tr("form.repository_files_already_exist.adopt_or_delete"), tplFork, form)
+ case setting.Repository.AllowAdoptionOfUnadoptedRepositories:
+ ctx.RenderWithErr(ctx.Tr("form.repository_files_already_exist.adopt"), tplFork, form)
+ case setting.Repository.AllowDeleteOfUnadoptedRepositories:
+ ctx.RenderWithErr(ctx.Tr("form.repository_files_already_exist.delete"), tplFork, form)
+ default:
+ ctx.RenderWithErr(ctx.Tr("form.repository_files_already_exist"), tplFork, form)
+ }
case db.IsErrNameReserved(err):
ctx.RenderWithErr(ctx.Tr("repo.form.name_reserved", err.(db.ErrNameReserved).Name), tplFork, &form)
case db.IsErrNamePatternNotAllowed(err):