From d432cf28ace98869c031b8f17da445beb00d6e66 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Thu, 4 Jun 2020 14:53:43 +0200 Subject: [PATCH 1/2] API: return an error when Mirrors globaly disabled --- 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 aefbffa8fa894..77ea5da044609 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("mirrors are global disabled")) + } + 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, From d284e61cdcd745922c5ca27d1bca4c871701dc61 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Thu, 4 Jun 2020 15:34:31 +0200 Subject: [PATCH 2/2] keep it consistent with UI Co-authored-by: John Olheiser --- routers/api/v1/repo/migrate.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routers/api/v1/repo/migrate.go b/routers/api/v1/repo/migrate.go index 77ea5da044609..43b5a7db3006e 100644 --- a/routers/api/v1/repo/migrate.go +++ b/routers/api/v1/repo/migrate.go @@ -114,7 +114,7 @@ func Migrate(ctx *context.APIContext, form auth.MigrateRepoForm) { } if form.Mirror && setting.Repository.DisableMirrors { - ctx.Error(http.StatusForbidden, "MirrorsGlobalDisabled", fmt.Errorf("mirrors are global disabled")) + ctx.Error(http.StatusForbidden, "MirrorsGlobalDisabled", fmt.Errorf("the site administrator has disabled mirrors")) } var opts = migrations.MigrateOptions{