summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
author6543 <6543@obermui.de>2020-06-04 18:11:28 +0200
committerGitHub <noreply@github.com>2020-06-04 12:11:28 -0400
commit0cb22121f4709dc1f5c863af53618c31302714e2 (patch)
tree6ddab4755f85103fd3a2c1f98798c789e653c90a
parentb534a5164fe13dc41aa2996239c2dff4f109dee0 (diff)
downloadgitea-0cb22121f4709dc1f5c863af53618c31302714e2.tar.gz
gitea-0cb22121f4709dc1f5c863af53618c31302714e2.zip
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 <john.olheiser@gmail.com> Co-authored-by: John Olheiser <john.olheiser@gmail.com>
-rw-r--r--routers/api/v1/repo/migrate.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/routers/api/v1/repo/migrate.go b/routers/api/v1/repo/migrate.go
index aefbffa8fa..43b5a7db30 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,