Hacker News new | ask | show | jobs
by keybored 2 days ago
> - git-multi-hook https://www.codeofhonor.com/projects/git-multi-hook/ git only allows one script per hook event; this is a dispatcher that discovers and runs every script in a hooks dir, in parallel, for both global and repo hooks.

Newest Git supports hook events.

1 comments

You are correct: git 2.54 supports multiple hooks via a the git repo and global configuration files.

Git-multi-hook predates that, but I updated it to use the new 2.54 config-based format.

The significant advantage of git-multi-hook is that they all run in parallel. I run eight hooks on precommit, so parallelism is a big win.

I will update the README to make note. Thanks!

git-hook documentation says that hook events can be configured to run in parallel.
Here's what gemini says about running hooks in parallel:

> Native Git traditionally executes hooks sequentially. However, you can achieve parallel execution by leveraging dedicated third-party hook managers or using built-in shell background processing

.. and that's what git-multi-hook is: a third-party hook manager, that uses shell background processing :)

Just out of curiousity, what are the 8 hooks you run?
The precommit checks I run are:

- end-with-blank-line: normalize file endings

- find-do-not-commit: do not commit files that include "DO NOT COMMIT"

- lint-code: run `$REPO/scripts/lint` if it exists

- lint-nodejs: run `$REPO/{pnpm/yarn/npm}` lint if `package.json` exists

- lint-shellcheck: shellcheck all the files that have no extensions or end in `.sh` that have a shell-shebang

- lint-swift: run swiftlint

- prevent-commit-secrets: run ripsecrets to avoid committing secrets and credentials

- validate: run `$REPO/scripts/validate` if it exists

By default all of the scripts check the files in the git staging area, but they can also be run standalone to check everything. You can find them here: https://github.com/webcoyote/git-multi-hook. Glad to take suggestions for more.

I see how it is.