From 0cb22121f4709dc1f5c863af53618c31302714e2 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Thu, 4 Jun 2020 18:11:28 +0200 Subject: [PATCH] API: Return error when Mirrors globaly disabled and like to create one (#11757) * API: return an error when Mirrors globaly disabled * keep it consistent with UI Co-authored-by: John Olheiser Co-authored-by: John Olheiser --- routers/api/v1/repo/migrate.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/routers/api/v1/repo/migrate.go b/routers/api/v1/repo/migrate.go index aefbffa8fa89..43b5a7db3006 100644 --- a/routers/api/v1/repo/migrate.go +++ b/routers/api/v1/repo/migrate.go @@ -113,12 +113,16 @@ func Migrate(ctx *context.APIContext, form auth.MigrateRepoForm) { gitServiceType = api.GithubService } + if form.Mirror && setting.Repository.DisableMirrors { + ctx.Error(http.StatusForbidden, "MirrorsGlobalDisabled", fmt.Errorf("the site administrator has disabled mirrors")) + } + var opts = migrations.MigrateOptions{ CloneAddr: remoteAddr, RepoName: form.RepoName, Description: form.Description, Private: form.Private || setting.Repository.ForcePrivate, - Mirror: form.Mirror && !setting.Repository.DisableMirrors, + Mirror: form.Mirror, AuthUsername: form.AuthUsername, AuthPassword: form.AuthPassword, Wiki: form.Wiki,