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>
tokarchuk/v1.17
6543 4 years ago committed by GitHub
parent b534a5164f
commit 0cb22121f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      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,

Loading…
Cancel
Save