Browse Source

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>
tags/v1.13.0-rc1
6543 GitHub 5 years ago
parent
commit
2eda045ec9
1 changed files with 5 additions and 1 deletions
  1. +5
    -1
      routers/api/v1/repo/migrate.go

+ 5
- 1
routers/api/v1/repo/migrate.go View File

@@ -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