diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index d52fe0556..2c2e85ca2 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -860,7 +860,7 @@ default_branch = Default Branch default_branch_helper = The default branch is the base branch for pull requests and code commits. mirror_prune = Prune mirror_prune_desc = Remove obsolete remote-tracking references -mirror_interval = Mirror Interval (valid time units are 'h', 'm', 's'). 0 to disable automatic sync. +mirror_interval = Mirror Interval (valid time units are 'h', 'm', 's'). 0 to disable automatic sync. (Minimum interval: %s) mirror_interval_invalid = The mirror interval is not valid. mirror_address = Clone From URL mirror_address_desc = Put any required credentials in the Authorization section. diff --git a/routers/web/repo/setting.go b/routers/web/repo/setting.go index b7be0aa3f..1a7a41ae9 100644 --- a/routers/web/repo/setting.go +++ b/routers/web/repo/setting.go @@ -65,11 +65,13 @@ func Settings(ctx *context.Context) { ctx.Data["MirrorsEnabled"] = setting.Mirror.Enabled ctx.Data["DisableNewPushMirrors"] = setting.Mirror.DisableNewPush ctx.Data["DefaultMirrorInterval"] = setting.Mirror.DefaultInterval + ctx.Data["MinimumMirrorInterval"] = setting.Mirror.MinInterval signing, _ := asymkey_service.SigningKey(ctx, ctx.Repo.Repository.RepoPath()) ctx.Data["SigningKeyAvailable"] = len(signing) > 0 ctx.Data["SigningSettings"] = setting.Repository.Signing ctx.Data["CodeIndexerEnabled"] = setting.Indexer.RepoIndexerEnabled + if ctx.Doer.IsAdmin { if setting.Indexer.RepoIndexerEnabled { status, err := repo_model.GetIndexerStatus(ctx, ctx.Repo.Repository, repo_model.RepoIndexerTypeCode) @@ -102,6 +104,17 @@ func SettingsPost(ctx *context.Context) { ctx.Data["Title"] = ctx.Tr("repo.settings") ctx.Data["PageIsSettingsOptions"] = true + ctx.Data["ForcePrivate"] = setting.Repository.ForcePrivate + ctx.Data["MirrorsEnabled"] = setting.Mirror.Enabled + ctx.Data["DisableNewPushMirrors"] = setting.Mirror.DisableNewPush + ctx.Data["DefaultMirrorInterval"] = setting.Mirror.DefaultInterval + ctx.Data["MinimumMirrorInterval"] = setting.Mirror.MinInterval + + signing, _ := asymkey_service.SigningKey(ctx, ctx.Repo.Repository.RepoPath()) + ctx.Data["SigningKeyAvailable"] = len(signing) > 0 + ctx.Data["SigningSettings"] = setting.Repository.Signing + ctx.Data["CodeIndexerEnabled"] = setting.Indexer.RepoIndexerEnabled + repo := ctx.Repo.Repository switch ctx.FormString("action") { @@ -191,15 +204,15 @@ func SettingsPost(ctx *context.Context) { if err != nil || (interval != 0 && interval < setting.Mirror.MinInterval) { ctx.Data["Err_Interval"] = true ctx.RenderWithErr(ctx.Tr("repo.mirror_interval_invalid"), tplSettingsOptions, &form) - } else { - ctx.Repo.Mirror.EnablePrune = form.EnablePrune - ctx.Repo.Mirror.Interval = interval - ctx.Repo.Mirror.ScheduleNextUpdate() - if err := repo_model.UpdateMirror(ctx, ctx.Repo.Mirror); err != nil { - ctx.Data["Err_Interval"] = true - ctx.RenderWithErr(ctx.Tr("repo.mirror_interval_invalid"), tplSettingsOptions, &form) - return - } + return + } + + ctx.Repo.Mirror.EnablePrune = form.EnablePrune + ctx.Repo.Mirror.Interval = interval + ctx.Repo.Mirror.ScheduleNextUpdate() + if err := repo_model.UpdateMirror(ctx, ctx.Repo.Mirror); err != nil { + ctx.ServerError("UpdateMirror", err) + return } u, _ := git.GetRemoteAddress(ctx, ctx.Repo.Repository.RepoPath(), ctx.Repo.Mirror.GetRemoteName()) diff --git a/templates/repo/settings/options.tmpl b/templates/repo/settings/options.tmpl index e2d6c5e1d..f44d9c98a 100644 --- a/templates/repo/settings/options.tmpl +++ b/templates/repo/settings/options.tmpl @@ -116,7 +116,7 @@