phillipuniverse / githook-maven-plugin

Maven plugin to install local git hooks
MIT License
28 stars 1 forks source link

Chain git-hooks instead of overwriting the existing one #7

Open dwightmulcahy opened 5 years ago

dwightmulcahy commented 5 years ago

I'm not really liking that this overwrites any existing git-hook without mercy.

See this for discussion... https://stackoverflow.com/questions/8730514/chaining-git-hooks

So this is what I'm envisioning, if an executable git-hook exists in the user's directory a "chain" would be added so that the newly installed script would be executed first and the user's chained to execute second.

dwightmulcahy commented 5 years ago

I have something cobbled together for this... need refactoring and some cleanup before I PR it.

phillipuniverse commented 5 years ago

I'm not really liking that this overwrites any existing git-hook without mercy.

Agree, obliterating what's already there isn't very nice.

So this is what I'm envisioning, if an executable git-hook exists in the user's directory a "chain" would be added so that the newly installed script would be executed first and the user's chained to execute second.

It looks like the chaining piece (at least what you linked in SO) is pretty platform-dependent as it relies on symlinks. We already have some Windows users (see #2) is there a way we can keep this compatible with both?

dwightmulcahy commented 5 years ago

...platform-dependent ... ...is there a way we can keep this compatible with both?

actually keeping it simple and just making the git-hook (like pre-commit) the hook-chain would do away with any symlinking.

One of the main issues I can think of now is that there would have to be some way to avoid continuing adding onto the "chain". Maybe a manifest of sha1/md5's?