Global core.hooksPath does not work #4430

Closed
opened 2025-11-02 05:50:25 -06:00 by GiteaMirror · 9 comments
Owner

Originally created by @gabyx on GitHub (Dec 2, 2019).

Does core.hooksPath work with gitea, it seems that after git init writes its own hooks into data/git/repositories/TestRepo/hooks ....
and also a set git config --global core.hooksPath <pathToMyHooks> does not help.
Only when the hooks reside in data/git/repositories/TestRepo/hooks then the hooks are triggered... ?

  • Gitea version (or commit ref): 1.11.0+dev-134-g4ee986e4c
  • Git version: 2.22
Originally created by @gabyx on GitHub (Dec 2, 2019). Does `core.hooksPath` work with gitea, it seems that after `git init` writes its own hooks into `data/git/repositories/TestRepo/hooks` .... and also a set `git config --global core.hooksPath <pathToMyHooks>` does not help. Only when the hooks reside in `data/git/repositories/TestRepo/hooks` then the hooks are triggered... ? - Gitea version (or commit ref): 1.11.0+dev-134-g4ee986e4c - Git version: 2.22
GiteaMirror added the type/enhancementissue/stale labels 2025-11-02 05:50:25 -06:00
Author
Owner

@stale[bot] commented on GitHub (Jan 31, 2020):

This issue has been automatically marked as stale because it has not had recent activity. I am here to help clear issues left open even if solved or waiting for more insight. This issue will be closed if no further activity occurs during the next 2 weeks. If the issue is still valid just add a comment to keep it alive. Thank you for your contributions.

@stale[bot] commented on GitHub (Jan 31, 2020): This issue has been automatically marked as stale because it has not had recent activity. I am here to help clear issues left open even if solved or waiting for more insight. This issue will be closed if no further activity occurs during the next 2 weeks. If the issue is still valid just add a comment to keep it alive. Thank you for your contributions.
Author
Owner

@6543 commented on GitHub (Jan 31, 2020):

@gabyx do you mean gitea ignore global git config of the user it run as?

@6543 commented on GitHub (Jan 31, 2020): @gabyx do you mean gitea ignore global git config of the user it run as?
Author
Owner

@gabyx commented on GitHub (Jan 31, 2020):

That could be but, so far, one should not change the behavior,
When gitea creates a new repo it should run

  • git init --bare
    • git sets up a repository and copies files from init.templateDir.
      Assume there are ${init.templateDir}/hooks which get installed
  • gitea somehow overwrites the hooks in hooks (it does not look at core.hooksPath which is good).

This overwritting behavior is problematic. It is clear that gitea needs to install the hooks somewhere, and thats not so trivial, since the admin (as me) could have setup a global hooks dispatcher (see https://github.com/rycus86/githooks)

A better strategy would be to call a customizable setup script which is run after gitea has created the bare repo. The default implementation is exactly as today, but so that we can adapt this script. A git config --global core.hooksPath should not be supported because it's the same for all repositories, gitea wants the flexibiliy to edit/save hooks from the web-interface fo each repository and needs to place them best in the repository's own hooks/update.d (etc..) folder...

This means the setup-script.sh is called like

bash setup-repo.sh "repoPath" "gitea-hooks-dir-to-be-placed"

In this way we can replace the initial hooks of gitea, replace them with the global hooks dispatcher and incorporate the gitea hooks.

@gabyx commented on GitHub (Jan 31, 2020): That could be but, so far, one should not change the behavior, When gitea creates a new repo it should run - `git init --bare` - git sets up a repository and copies files from `init.templateDir`. Assume there are `${init.templateDir}/hooks` which get installed - gitea somehow overwrites the hooks in `hooks` (it does not look at `core.hooksPath` which is good). This overwritting behavior is **problematic**. It is clear that gitea **needs** to install the hooks somewhere, and thats not so trivial, since the admin (as me) could have setup a global hooks dispatcher (see https://github.com/rycus86/githooks) A **better strategy** would be to call a customizable **setup script** which is run after gitea has created the bare repo. The default implementation is exactly as today, but so that we can adapt this script. A `git config --global core.hooksPath` should not be supported because it's the same for all repositories, gitea wants the flexibiliy to edit/save hooks from the web-interface fo each repository and needs to place them best in the repository's own `hooks/update.d` (etc..) folder... This means the `setup-script.sh` is called like ```shell bash setup-repo.sh "repoPath" "gitea-hooks-dir-to-be-placed" ``` In this way we can replace the initial hooks of gitea, replace them with the global hooks dispatcher and incorporate the gitea hooks.
Author
Owner

@stale[bot] commented on GitHub (Apr 3, 2020):

This issue has been automatically marked as stale because it has not had recent activity. I am here to help clear issues left open even if solved or waiting for more insight. This issue will be closed if no further activity occurs during the next 2 weeks. If the issue is still valid just add a comment to keep it alive. Thank you for your contributions.

@stale[bot] commented on GitHub (Apr 3, 2020): This issue has been automatically marked as stale because it has not had recent activity. I am here to help clear issues left open even if solved or waiting for more insight. This issue will be closed if no further activity occurs during the next 2 weeks. If the issue is still valid just add a comment to keep it alive. Thank you for your contributions.
Author
Owner

@6543 commented on GitHub (Apr 4, 2020):

ping

@6543 commented on GitHub (Apr 4, 2020): ping
Author
Owner

@stale[bot] commented on GitHub (Jun 3, 2020):

This issue has been automatically marked as stale because it has not had recent activity. I am here to help clear issues left open even if solved or waiting for more insight. This issue will be closed if no further activity occurs during the next 2 weeks. If the issue is still valid just add a comment to keep it alive. Thank you for your contributions.

@stale[bot] commented on GitHub (Jun 3, 2020): This issue has been automatically marked as stale because it has not had recent activity. I am here to help clear issues left open even if solved or waiting for more insight. This issue will be closed if no further activity occurs during the next 2 weeks. If the issue is still valid just add a comment to keep it alive. Thank you for your contributions.
Author
Owner

@zeripath commented on GitHub (Jun 3, 2020):

I've still not had a chance to actually properly investigate this

@zeripath commented on GitHub (Jun 3, 2020): I've still not had a chance to actually properly investigate this
Author
Owner

@gabyx commented on GitHub (Jun 4, 2020):

I think it was only a user problem. But the enhancement would be beneficial.

@gabyx commented on GitHub (Jun 4, 2020): I think it was only a user problem. But the enhancement would be beneficial.
Author
Owner

@stale[bot] commented on GitHub (Aug 3, 2020):

This issue has been automatically marked as stale because it has not had recent activity. I am here to help clear issues left open even if solved or waiting for more insight. This issue will be closed if no further activity occurs during the next 2 weeks. If the issue is still valid just add a comment to keep it alive. Thank you for your contributions.

@stale[bot] commented on GitHub (Aug 3, 2020): This issue has been automatically marked as stale because it has not had recent activity. I am here to help clear issues left open even if solved or waiting for more insight. This issue will be closed if no further activity occurs during the next 2 weeks. If the issue is still valid just add a comment to keep it alive. Thank you for your contributions.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#4430