Skip to content

Commit 0cb2212

Browse files
6543jolheiser
andauthored
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 <[email protected]> Co-authored-by: John Olheiser <[email protected]>
1 parent b534a51 commit 0cb2212

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

routers/api/v1/repo/migrate.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,16 @@ func Migrate(ctx *context.APIContext, form auth.MigrateRepoForm) {
113113
gitServiceType = api.GithubService
114114
}
115115

116+
if form.Mirror && setting.Repository.DisableMirrors {
117+
ctx.Error(http.StatusForbidden, "MirrorsGlobalDisabled", fmt.Errorf("the site administrator has disabled mirrors"))
118+
}
119+
116120
var opts = migrations.MigrateOptions{
117121
CloneAddr: remoteAddr,
118122
RepoName: form.RepoName,
119123
Description: form.Description,
120124
Private: form.Private || setting.Repository.ForcePrivate,
121-
Mirror: form.Mirror && !setting.Repository.DisableMirrors,
125+
Mirror: form.Mirror,
122126
AuthUsername: form.AuthUsername,
123127
AuthPassword: form.AuthPassword,
124128
Wiki: form.Wiki,

0 commit comments

Comments
 (0)