I am planning to write a few git hooks as a project which logs the user's actions in a database. This database can then be used for querying for all his activities. The actions I am trying to log are
- commit
- pull
- push
- merge
- branch
I want to get this packaged in distros which can be installed via package manager.
Git allows global hooks by placing any such in $PREFIX/share/templates/hooks
It currently has some hooks which are disabled (.sample
is appended to their name). When a new repository is created, these hooks are copied in the .git
folder of the repository
Now if a user installs the package for these hooks and hooks like post-commit
and post-update
are already enabled. In this case the script file will be overwritten! This sounds bad
This means git has only one hook file per action. If I need to keep three hooks for one action, it means it is not possible. This means automated install from package manager can introduce conflicts.
Now think that we packaged the hooks to overwrite the default enabled file. If a user wants to add some more actions to those file and then decided to uninstall my package, then his custom command would also be gone?
I thought that git was pretty clever in this regard and I was wrong :(
There needs to be a folder named post-commit
and post-update
or whatever actions and git should run all the scripts inside that folder. I am still hunting a way to deal with the current situation.