From 02b45051503d4330da9757ff084c9cc5e6e60d84 Mon Sep 17 00:00:00 2001 From: Pawel Boguslawski Date: Tue, 1 Feb 2022 15:54:01 +0100 Subject: [PATCH 1/5] 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 --- custom/conf/app.example.ini | 2 +- docs/content/doc/advanced/config-cheat-sheet.en-us.md | 2 +- options/locale/locale_en-US.ini | 1 - routers/web/user/home.go | 1 + services/cron/tasks_basic.go | 4 +++- templates/repo/migrate/options.tmpl | 11 +++-------- templates/user/dashboard/repolist.tmpl | 2 ++ 7 files changed, 11 insertions(+), 12 deletions(-) diff --git a/custom/conf/app.example.ini b/custom/conf/app.example.ini index 586c924c4ab8..20b2db71794b 100644 --- a/custom/conf/app.example.ini +++ b/custom/conf/app.example.ini @@ -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 diff --git a/docs/content/doc/advanced/config-cheat-sheet.en-us.md b/docs/content/doc/advanced/config-cheat-sheet.en-us.md index 6cbc9b91f985..c92a518d9f2c 100644 --- a/docs/content/doc/advanced/config-cheat-sheet.en-us.md +++ b/docs/content/doc/advanced/config-cheat-sheet.en-us.md @@ -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 diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index d8398f6d9fc5..fd8b16276237 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -908,7 +908,6 @@ need_auth = Authorization migrate_options = Migration Options migrate_service = Migration Service migrate_options_mirror_helper = This repository will be a mirror -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 determine the LFS server. You can also specify a custom endpoint if the repository LFS data is stored somewhere else. diff --git a/routers/web/user/home.go b/routers/web/user/home.go index 367cf5ca0849..f43fd38bf2f2 100644 --- a/routers/web/user/home.go +++ b/routers/web/user/home.go @@ -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 { diff --git a/services/cron/tasks_basic.go b/services/cron/tasks_basic.go index fdf8550c31fb..b4a549d636a2 100644 --- a/services/cron/tasks_basic.go +++ b/services/cron/tasks_basic.go @@ -141,7 +141,9 @@ func registerCleanupHookTaskTable() { } func initBasicTasks() { - registerUpdateMirrorTask() + if setting.Mirror.Enabled { + registerUpdateMirrorTask() + } registerRepoHealthCheck() registerCheckRepoStats() registerArchiveCleanup() diff --git a/templates/repo/migrate/options.tmpl b/templates/repo/migrate/options.tmpl index 8aefaf68f12b..2c3e42352c15 100644 --- a/templates/repo/migrate/options.tmpl +++ b/templates/repo/migrate/options.tmpl @@ -1,13 +1,8 @@ -
+
- {{if .DisableNewPullMirrors}} - - - {{else}} - - - {{end}} + +
{{if .LFSActive}} diff --git a/templates/user/dashboard/repolist.tmpl b/templates/user/dashboard/repolist.tmpl index 41230d3287e2..4fed37d5e121 100644 --- a/templates/user/dashboard/repolist.tmpl +++ b/templates/user/dashboard/repolist.tmpl @@ -109,10 +109,12 @@ {{.i18n.Tr "forks"}}
${repoTypeCount}
+ {{if not .DisableNewPullMirrors}} {{.i18n.Tr "mirrors"}}
${repoTypeCount}
+ {{end}} {{.i18n.Tr "collaborative"}}
${repoTypeCount}
From 0d45d0c2a020f4275d7d3084471d2cffe3c80374 Mon Sep 17 00:00:00 2001 From: Pawel Boguslawski Date: Fri, 11 Feb 2022 10:48:55 +0100 Subject: [PATCH 2/5] Checkbox rendering disabled instead of hiding it Fixes: 02b45051503d4330da9757ff084c9cc5e6e60d84 Related: https://github.com/go-gitea/gitea/pull/18527#pullrequestreview-878061913 Author-Change-Id: IB#1105104 --- templates/repo/migrate/options.tmpl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/templates/repo/migrate/options.tmpl b/templates/repo/migrate/options.tmpl index 2c3e42352c15..bb2a6ed77f78 100644 --- a/templates/repo/migrate/options.tmpl +++ b/templates/repo/migrate/options.tmpl @@ -1,10 +1,12 @@ -
+{{if not .DisableNewPullMirrors}} +
- +
+{{end}} {{if .LFSActive}}
From e085958235a5cffe3bb60d1292825a3f136f68de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bogus=C5=82awski?= Date: Fri, 11 Feb 2022 11:33:04 +0100 Subject: [PATCH 3/5] Update custom/conf/app.example.ini Co-authored-by: silverwind --- custom/conf/app.example.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom/conf/app.example.ini b/custom/conf/app.example.ini index 20b2db71794b..690885e4629f 100644 --- a/custom/conf/app.example.ini +++ b/custom/conf/app.example.ini @@ -1996,7 +1996,7 @@ PATH = ;[mirror] ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; 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). +;; 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 From 07f6120c3c573f612071f13692020be983e5714b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bogus=C5=82awski?= Date: Fri, 11 Feb 2022 11:33:13 +0100 Subject: [PATCH 4/5] Update docs/content/doc/advanced/config-cheat-sheet.en-us.md Co-authored-by: silverwind --- docs/content/doc/advanced/config-cheat-sheet.en-us.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/content/doc/advanced/config-cheat-sheet.en-us.md b/docs/content/doc/advanced/config-cheat-sheet.en-us.md index c92a518d9f2c..7d9adf732178 100644 --- a/docs/content/doc/advanced/config-cheat-sheet.en-us.md +++ b/docs/content/doc/advanced/config-cheat-sheet.en-us.md @@ -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 (pre-existing mirrors remain valid but won't be updated; may be converted to regular repo). +- `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 From b1c36319891a8729e54f04681107e1f1ec5d38a5 Mon Sep 17 00:00:00 2001 From: Pawel Boguslawski Date: Fri, 3 Jun 2022 21:07:21 +0200 Subject: [PATCH 5/5] Mirror filter removed only when whole mirroring feature is disabled Fixes: 02b45051503d4330da9757ff084c9cc5e6e60d84 Related: https://github.com/go-gitea/gitea/pull/18527#discussion_r883268890 Author-Change-Id: IB#1105104 --- routers/web/user/home.go | 2 +- templates/user/dashboard/repolist.tmpl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/routers/web/user/home.go b/routers/web/user/home.go index f43fd38bf2f2..b7c64ccff5a0 100644 --- a/routers/web/user/home.go +++ b/routers/web/user/home.go @@ -77,7 +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 + ctx.Data["MirrorsEnabled"] = setting.Mirror.Enabled var uid int64 if ctxUser != nil { diff --git a/templates/user/dashboard/repolist.tmpl b/templates/user/dashboard/repolist.tmpl index 4fed37d5e121..b2f936402d2e 100644 --- a/templates/user/dashboard/repolist.tmpl +++ b/templates/user/dashboard/repolist.tmpl @@ -109,7 +109,7 @@ {{.i18n.Tr "forks"}}
${repoTypeCount}
- {{if not .DisableNewPullMirrors}} + {{if .MirrorsEnabled}} {{.i18n.Tr "mirrors"}}
${repoTypeCount}