0

I have a functional commit-msg git hook that takes the string from beginning up to the first underscore from a git branch's name and prepends it to the commit message.

For better understanding: The branch name is JIRA-123_fix_problem, the commit command goes: git commit -m 'Fix problem' and through the commit-msg hook the commit message will automatically be changed into JIRA-123: Fix problem.

Now we're using Nuxt for our current Vuejs project and this makes use of husky. We want to keep husky in this project. Unfortunately (and, I guess, intentionally), husky works by overwriting the git commit hooks, and thus the file .git/hooks/commit-msg I use will be overwritten by husky and the original commit-msg hook does not work any more.

How can I either prevent husky from overwriting the commit-msg hook or instruct husky to do the same thing?

I can't find any documentation for this problem.

RSeidelsohn
  • 1,149
  • 18
  • 33

1 Answers1

0

Ok, I finally found (and verified) the soution:

In this husky issue ("Support custom git hooks to be not overridden by husky #323") typicode says:

Husky is overwriting file, because there [is] # husky in it. It checks for this string to know if it's a user script or if it has been generared by husky.

If you delete # husky, it will never overwrite them again.

After I removed the # husky line, re-installing all node modules in our project finally keeps the commit-msg hook I want to use. I originally just copied & pasted the code while maintaining the # husky line from the scaffolding of the project.

RSeidelsohn
  • 1,149
  • 18
  • 33