Disable unnecessary mirroring elements

This mod fixes disabling unnecessary mirroring elements.

Related: https://github.com/go-gitea/gitea/pull/16957
Related: https://github.com/go-gitea/gitea/pull/13084
Author-Change-Id: IB#1105104
This commit is contained in:
Pawel Boguslawski 2022-02-01 15:54:01 +01:00
parent b7c6457648
commit 02b4505150
7 changed files with 11 additions and 12 deletions

View File

@ -1996,7 +1996,7 @@ PATH =
;[mirror]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Enables the mirror functionality. Set to **false** to disable all mirrors.
;; Enables the mirror functionality. Set to **false** to disable all mirrors (pre-existing mirrors remain valid but won't be updated; may be converted to regular repo).
;ENABLED = true
;; Disable the creation of **new** pull mirrors. Pre-existing mirrors remain valid. Will be ignored if `mirror.ENABLED` is `false`.
;DISABLE_NEW_PULL = false

View File

@ -1061,7 +1061,7 @@ Task queue configuration has been moved to `queue.task`. However, the below conf
## Mirror (`mirror`)
- `ENABLED`: **true**: Enables the mirror functionality. Set to **false** to disable all mirrors.
- `ENABLED`: **true**: Enables the mirror functionality. Set to **false** to disable all mirrors (pre-existing mirrors remain valid but won't be updated; may be converted to regular repo).
- `DISABLE_NEW_PULL`: **false**: Disable the creation of **new** pull mirrors. Pre-existing mirrors remain valid. Will be ignored if `mirror.ENABLED` is `false`.
- `DISABLE_NEW_PUSH`: **false**: Disable the creation of **new** push mirrors. Pre-existing mirrors remain valid. Will be ignored if `mirror.ENABLED` is `false`.
- `DEFAULT_INTERVAL`: **8h**: Default interval between each check

View File

@ -908,7 +908,6 @@ need_auth = Authorization
migrate_options = Migration Options
migrate_service = Migration Service
migrate_options_mirror_helper = This repository will be a <span class="text blue">mirror</span>
migrate_options_mirror_disabled = Your site administrator has disabled new mirrors.
migrate_options_lfs = Migrate LFS files
migrate_options_lfs_endpoint.label = LFS Endpoint
migrate_options_lfs_endpoint.description = Migration will attempt to use your Git remote to <a target="_blank" rel="noopener noreferrer" href="%s">determine the LFS server</a>. You can also specify a custom endpoint if the repository LFS data is stored somewhere else.

View File

@ -77,6 +77,7 @@ func Dashboard(ctx *context.Context) {
ctx.Data["PageIsNews"] = true
cnt, _ := models.GetOrganizationCount(db.DefaultContext, ctxUser)
ctx.Data["UserOrgsCount"] = cnt
ctx.Data["DisableNewPullMirrors"] = setting.Mirror.DisableNewPull
var uid int64
if ctxUser != nil {

View File

@ -141,7 +141,9 @@ func registerCleanupHookTaskTable() {
}
func initBasicTasks() {
registerUpdateMirrorTask()
if setting.Mirror.Enabled {
registerUpdateMirrorTask()
}
registerRepoHealthCheck()
registerCheckRepoStats()
registerArchiveCleanup()

View File

@ -1,13 +1,8 @@
<div class="inline field">
<div class="inline field" {{if .DisableNewPullMirrors}} hidden{{end}}>
<label>{{.i18n.Tr "repo.migrate_options"}}</label>
<div class="ui checkbox">
{{if .DisableNewPullMirrors}}
<input id="mirror" name="mirror" type="checkbox" readonly>
<label>{{.i18n.Tr "repo.migrate_options_mirror_disabled"}}</label>
{{else}}
<input id="mirror" name="mirror" type="checkbox" {{if .mirror}} checked{{end}}>
<label>{{.i18n.Tr "repo.migrate_options_mirror_helper" | Safe}}</label>
{{end}}
<input id="mirror" name="mirror" type="checkbox" {{if and .mirror (not .DisableNewPullMirrors)}} checked{{end}}>
<label>{{.i18n.Tr "repo.migrate_options_mirror_helper" | Safe}}</label>
</div>
</div>
{{if .LFSActive}}

View File

@ -109,10 +109,12 @@
{{.i18n.Tr "forks"}}
<div v-show="reposFilter === 'forks'" class="ui circular mini grey label">${repoTypeCount}</div>
</a>
{{if not .DisableNewPullMirrors}}
<a class="item" :class="{active: reposFilter === 'mirrors'}" @click="changeReposFilter('mirrors')">
{{.i18n.Tr "mirrors"}}
<div v-show="reposFilter === 'mirrors'" class="ui circular mini grey label">${repoTypeCount}</div>
</a>
{{end}}
<a class="item" :class="{active: reposFilter === 'collaborative'}" @click="changeReposFilter('collaborative')">
{{.i18n.Tr "collaborative"}}
<div v-show="reposFilter === 'collaborative'" class="ui circular mini grey label">${repoTypeCount}</div>