Skip to content

Commit

Permalink
API: Return error when Mirrors globaly disabled and like to create one (
Browse files Browse the repository at this point in the history
go-gitea#11757)

* API: return an error when Mirrors globaly disabled

* keep it consistent with UI

Co-authored-by: John Olheiser <[email protected]>

Co-authored-by: John Olheiser <[email protected]>
  • Loading branch information
2 people authored and Yohann Delafollye committed Jul 31, 2020
1 parent 6757c0d commit f92edf7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion routers/api/v1/repo/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit f92edf7

Please sign in to comment.