Skip to content

Commit d7959c7

Browse files
committed
Ensure minimum mirror interval is reported on settings page
Expecting users to guess the minimum mirror interval appears a little unkind. In this PR we simply change the locale string to include the minimum interval. This will of course be affected by our current localization framework but... we can fix that else where. This PR also includes some fixes for error handling on the settings page as previously the mirror block amongst others would simply disappear on error. Fix go-gitea#3737 Signed-off-by: Andrew Thornton <[email protected]>
1 parent 73382d2 commit d7959c7

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

options/locale/locale_en-US.ini

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -860,7 +860,7 @@ default_branch = Default Branch
860860
default_branch_helper = The default branch is the base branch for pull requests and code commits.
861861
mirror_prune = Prune
862862
mirror_prune_desc = Remove obsolete remote-tracking references
863-
mirror_interval = Mirror Interval (valid time units are 'h', 'm', 's'). 0 to disable automatic sync.
863+
mirror_interval = Mirror Interval (valid time units are 'h', 'm', 's'). 0 to disable automatic sync. (Minimum interval: %v)
864864
mirror_interval_invalid = The mirror interval is not valid.
865865
mirror_address = Clone From URL
866866
mirror_address_desc = Put any required credentials in the Authorization section.
@@ -1532,6 +1532,7 @@ pulls.data_broken = This pull request is broken due to missing fork information.
15321532
pulls.files_conflicted = This pull request has changes conflicting with the target branch.
15331533
pulls.is_checking = "Merge conflict checking is in progress. Try again in few moments."
15341534
pulls.is_empty = "This branch is equal with the target branch."
1535+
pulls.is_empty_differing_head_merge_base = "This branch ."
15351536
pulls.required_status_check_failed = Some required checks were not successful.
15361537
pulls.required_status_check_missing = Some required checks are missing.
15371538
pulls.required_status_check_administrator = As an administrator, you may still merge this pull request.

routers/web/repo/setting.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,13 @@ func Settings(ctx *context.Context) {
6565
ctx.Data["MirrorsEnabled"] = setting.Mirror.Enabled
6666
ctx.Data["DisableNewPushMirrors"] = setting.Mirror.DisableNewPush
6767
ctx.Data["DefaultMirrorInterval"] = setting.Mirror.DefaultInterval
68+
ctx.Data["MinimumMirrorInterval"] = setting.Mirror.MinInterval
6869

6970
signing, _ := asymkey_service.SigningKey(ctx, ctx.Repo.Repository.RepoPath())
7071
ctx.Data["SigningKeyAvailable"] = len(signing) > 0
7172
ctx.Data["SigningSettings"] = setting.Repository.Signing
7273
ctx.Data["CodeIndexerEnabled"] = setting.Indexer.RepoIndexerEnabled
74+
7375
if ctx.Doer.IsAdmin {
7476
if setting.Indexer.RepoIndexerEnabled {
7577
status, err := repo_model.GetIndexerStatus(ctx, ctx.Repo.Repository, repo_model.RepoIndexerTypeCode)
@@ -102,6 +104,17 @@ func SettingsPost(ctx *context.Context) {
102104
ctx.Data["Title"] = ctx.Tr("repo.settings")
103105
ctx.Data["PageIsSettingsOptions"] = true
104106

107+
ctx.Data["ForcePrivate"] = setting.Repository.ForcePrivate
108+
ctx.Data["MirrorsEnabled"] = setting.Mirror.Enabled
109+
ctx.Data["DisableNewPushMirrors"] = setting.Mirror.DisableNewPush
110+
ctx.Data["DefaultMirrorInterval"] = setting.Mirror.DefaultInterval
111+
ctx.Data["MinimumMirrorInterval"] = setting.Mirror.MinInterval
112+
113+
signing, _ := asymkey_service.SigningKey(ctx, ctx.Repo.Repository.RepoPath())
114+
ctx.Data["SigningKeyAvailable"] = len(signing) > 0
115+
ctx.Data["SigningSettings"] = setting.Repository.Signing
116+
ctx.Data["CodeIndexerEnabled"] = setting.Indexer.RepoIndexerEnabled
117+
105118
repo := ctx.Repo.Repository
106119

107120
switch ctx.FormString("action") {
@@ -191,13 +204,13 @@ func SettingsPost(ctx *context.Context) {
191204
if err != nil || (interval != 0 && interval < setting.Mirror.MinInterval) {
192205
ctx.Data["Err_Interval"] = true
193206
ctx.RenderWithErr(ctx.Tr("repo.mirror_interval_invalid"), tplSettingsOptions, &form)
207+
return
194208
} else {
195209
ctx.Repo.Mirror.EnablePrune = form.EnablePrune
196210
ctx.Repo.Mirror.Interval = interval
197211
ctx.Repo.Mirror.ScheduleNextUpdate()
198212
if err := repo_model.UpdateMirror(ctx, ctx.Repo.Mirror); err != nil {
199-
ctx.Data["Err_Interval"] = true
200-
ctx.RenderWithErr(ctx.Tr("repo.mirror_interval_invalid"), tplSettingsOptions, &form)
213+
ctx.ServerError("UpdateMirror", err)
201214
return
202215
}
203216
}

templates/repo/settings/options.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@
116116
</div>
117117
</div>
118118
<div class="inline field {{if .Err_Interval}}error{{end}}">
119-
<label for="interval">{{.i18n.Tr "repo.mirror_interval"}}</label>
119+
<label for="interval">{{.i18n.Tr "repo.mirror_interval" .MinimumMirrorInterval}}</label>
120120
<input id="interval" name="interval" value="{{.MirrorInterval}}">
121121
</div>
122122
{{$address := MirrorRemoteAddress $.Context .Mirror}}
@@ -220,7 +220,7 @@
220220
</div>
221221
</details>
222222
<div class="inline field {{if .Err_PushMirrorInterval}}error{{end}}">
223-
<label for="push_mirror_interval">{{.i18n.Tr "repo.mirror_interval"}}</label>
223+
<label for="push_mirror_interval">{{.i18n.Tr "repo.mirror_interval" .MinimumMirrorInterval}}</label>
224224
<input id="push_mirror_interval" name="push_mirror_interval" value="{{if .push_mirror_interval}}{{.push_mirror_interval}}{{else}}{{.DefaultMirrorInterval}}{{end}}">
225225
</div>
226226
<div class="field">

0 commit comments

Comments
 (0)