bk201- / jira-prepare-commit-msg

Husky Git hook to add JIRA ticket ID into the commit message.
MIT License
116 stars 37 forks source link

add support for husky 9 #744

Open aedison-tw opened 5 months ago

aedison-tw commented 5 months ago

Unusable with husky v9

When using husky 9, the command fails with husky install is deprecated and husky add is deprecated:

~/temp_repositories/deletemerepo on main ?1 ........................................................................................................................................ took 9s at 20:15:40
> npm install husky jira-prepare-commit-msg --save-dev && npx husky install

added 27 packages, and audited 28 packages in 1s

4 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
install command is deprecated
~/temp_repositories/deletemerepo on main ?3 ................................................................................................................................................ at 20:16:08
> npx husky add .husky/prepare-commit-msg 'npx jira-prepare-commit-msg $1'
add command is deprecated

Workaround

Use husky v8 instead for now until husky 9 support is added

npm install husky@8.0.3 jira-prepare-commit-msg --save-dev && npx husky install
InSuperposition commented 1 month ago

After reviewing the husky docs for a new hook.

using git's prepare-commit-msg hook worked for me.

echo "npx jira-prepare-commit-msg $1" > .husky/prepare-commit-msg
jt-metatheory commented 1 month ago

The issue is that the new Husky system requires exiting with code !=0 to stop processing. so preparing commits is fine but pre-commit hooks don't work.