From 6801919631af7d94f175e89166cfd9470a6e0ac8 Mon Sep 17 00:00:00 2001 From: Pawel Boguslawski Date: Mon, 31 Jan 2022 15:12:47 +0100 Subject: [PATCH 1/5] Disable unnecessary GitHooks elements This mod fixes disabling unnecessary GitHooks elements. Related: https://github.com/go-gitea/gitea/pull/13129 Author-Change-Id: IB#1115251 --- services/cron/tasks_extended.go | 4 +++- templates/admin/dashboard.tmpl | 2 ++ templates/admin/user/edit.tmpl | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/services/cron/tasks_extended.go b/services/cron/tasks_extended.go index ded819a71e91..3701624a8ac6 100644 --- a/services/cron/tasks_extended.go +++ b/services/cron/tasks_extended.go @@ -160,7 +160,9 @@ func initExtendedTasks() { registerGarbageCollectRepositories() registerRewriteAllPublicKeys() registerRewriteAllPrincipalKeys() - registerRepositoryUpdateHook() + if !setting.DisableGitHooks { + registerRepositoryUpdateHook() + } registerReinitMissingRepositories() registerDeleteMissingRepositories() registerRemoveRandomAvatars() diff --git a/templates/admin/dashboard.tmpl b/templates/admin/dashboard.tmpl index 35f45bd3529c..b53fa3cddc2f 100644 --- a/templates/admin/dashboard.tmpl +++ b/templates/admin/dashboard.tmpl @@ -52,10 +52,12 @@ {{end}} + {{if not DisableGitHooks}} {{.i18n.Tr "admin.dashboard.resync_all_hooks"}} + {{end}} {{.i18n.Tr "admin.dashboard.reinit_missing_repos"}} diff --git a/templates/admin/user/edit.tmpl b/templates/admin/user/edit.tmpl index 17bd2b936c5e..1ee46f3077a3 100644 --- a/templates/admin/user/edit.tmpl +++ b/templates/admin/user/edit.tmpl @@ -116,7 +116,7 @@ -
+
From 6437b04c01c3f14fd26286d5c92d6b143b3d1bb9 Mon Sep 17 00:00:00 2001 From: Pawel Boguslawski Date: Mon, 31 Jan 2022 15:43:18 +0100 Subject: [PATCH 2/5] Div hiding fixed Fixes: 6801919631af7d94f175e89166cfd9470a6e0ac8 Author-Change-Id: IB#1115251 --- templates/admin/user/edit.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/admin/user/edit.tmpl b/templates/admin/user/edit.tmpl index 1ee46f3077a3..526fcfcd6cb8 100644 --- a/templates/admin/user/edit.tmpl +++ b/templates/admin/user/edit.tmpl @@ -116,7 +116,7 @@
-
+
From 8a0eb58b0f1d540c48f5803fa9c74ff097f06569 Mon Sep 17 00:00:00 2001 From: Pawel Boguslawski Date: Mon, 31 Jan 2022 15:58:16 +0100 Subject: [PATCH 3/5] Div hiding fix reverted Placing hidden as CSS class only greys out this option; we want to hide it. According to https://stackoverflow.com/questions/1992114/how-do-you-create-a-hidden-div-that-doesnt-create-a-line-break-or-horizontal-sp/27548863#27548863 using hidden as attribute is ok and works ok in gitea. Fixes: 6437b04c01c3f14fd26286d5c92d6b143b3d1bb9 Author-Change-Id: IB#1115251 --- templates/admin/user/edit.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/admin/user/edit.tmpl b/templates/admin/user/edit.tmpl index 526fcfcd6cb8..1ee46f3077a3 100644 --- a/templates/admin/user/edit.tmpl +++ b/templates/admin/user/edit.tmpl @@ -116,7 +116,7 @@
-
+
From 708319e4e9e2c9e797cc7dccfaa9ec7fe9a210eb Mon Sep 17 00:00:00 2001 From: Pawel Boguslawski Date: Tue, 1 Feb 2022 13:07:55 +0100 Subject: [PATCH 4/5] Comment about adjusting existing repo hooks added Fixes: 6801919631af7d94f175e89166cfd9470a6e0ac8 Related: https://github.com/go-gitea/gitea/pull/18485#pullrequestreview-868633019 Author-Change-Id: IB#1115251 --- custom/conf/app.example.ini | 1 + docs/content/doc/advanced/config-cheat-sheet.en-us.md | 1 + 2 files changed, 2 insertions(+) diff --git a/custom/conf/app.example.ini b/custom/conf/app.example.ini index 586c924c4ab8..41c1c17add90 100644 --- a/custom/conf/app.example.ini +++ b/custom/conf/app.example.ini @@ -367,6 +367,7 @@ INTERNAL_TOKEN= ;; By modifying the Gitea database, users can gain Gitea administrator privileges. ;; It also enables them to access other resources available to the user on the operating system that is running the Gitea instance and perform arbitrary actions in the name of the Gitea OS user. ;; WARNING: This maybe harmful to you website or your operating system. +;; WARNING: Setting this to true does not change existing hooks in git repos; adjust it before if necessary. ;DISABLE_GIT_HOOKS = true ;; ;; Set to true to disable webhooks feature. 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..0d7b63ddee9b 100644 --- a/docs/content/doc/advanced/config-cheat-sheet.en-us.md +++ b/docs/content/doc/advanced/config-cheat-sheet.en-us.md @@ -497,6 +497,7 @@ Certain queues have defaults that override the defaults set in `[queue]` (this o It also enables them to access other resources available to the user on the operating system that is running the Gitea instance and perform arbitrary actions in the name of the Gitea OS user. This maybe harmful to you website or your operating system. + Setting this to true does not change existing hooks in git repos; adjust it before if necessary. - `DISABLE_WEBHOOKS`: **false**: Set to `true` to disable webhooks feature. - `ONLY_ALLOW_PUSH_IF_GITEA_ENVIRONMENT_SET`: **true**: Set to `false` to allow local users to push to gitea-repositories without setting up the Gitea environment. This is not recommended and if you want local users to push to Gitea repositories you should set the environment appropriately. - `IMPORT_LOCAL_PATHS`: **false**: Set to `false` to prevent all users (including admin) from importing local path on server. From 97a5d84f7a1b7e8af87f148c2b2b78125cee200e Mon Sep 17 00:00:00 2001 From: Pawel Boguslawski Date: Wed, 2 Feb 2022 11:07:57 +0100 Subject: [PATCH 5/5] Git hooks cron job should not be disabled when DISABLE_GIT_HOOKS=true Fixes: 6801919631af7d94f175e89166cfd9470a6e0ac8 Related: https://github.com/go-gitea/gitea/pull/18485#pullrequestreview-870056925 Author-Change-Id: IB#1115251 --- services/cron/tasks_extended.go | 4 +--- templates/admin/dashboard.tmpl | 2 -- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/services/cron/tasks_extended.go b/services/cron/tasks_extended.go index 3701624a8ac6..ded819a71e91 100644 --- a/services/cron/tasks_extended.go +++ b/services/cron/tasks_extended.go @@ -160,9 +160,7 @@ func initExtendedTasks() { registerGarbageCollectRepositories() registerRewriteAllPublicKeys() registerRewriteAllPrincipalKeys() - if !setting.DisableGitHooks { - registerRepositoryUpdateHook() - } + registerRepositoryUpdateHook() registerReinitMissingRepositories() registerDeleteMissingRepositories() registerRemoveRandomAvatars() diff --git a/templates/admin/dashboard.tmpl b/templates/admin/dashboard.tmpl index b53fa3cddc2f..35f45bd3529c 100644 --- a/templates/admin/dashboard.tmpl +++ b/templates/admin/dashboard.tmpl @@ -52,12 +52,10 @@ {{end}} - {{if not DisableGitHooks}} {{.i18n.Tr "admin.dashboard.resync_all_hooks"}} - {{end}} {{.i18n.Tr "admin.dashboard.reinit_missing_repos"}}