| Crates.io | git-hooks-dispatch |
| lib.rs | git-hooks-dispatch |
| version | 0.4.2 |
| created_at | 2021-08-01 03:27:38.242162+00 |
| updated_at | 2021-08-31 02:29:22.00095+00 |
| description | Run hooks only in a directory where files are changed. Useful for monorepo. |
| homepage | |
| repository | https://github.com/akr4/git-hooks-dispatch |
| max_upload_size | |
| id | 429881 |
| size | 37,807 |
Run hooks only in a directory where files are changed. Useful for monorepo.
cargo install git-hooks-dispatch
Set up hooks you want as the following:
Hook file (e.g. .git/hooks/pre-commit)
#!/bin/sh
git-hooks-dispatch $(basename $0) -- "$@"
Make sure the file has permission to execute.
Then, in the child directories, you can set up hooks as they are in the project root directory.
For example:
./sub-project1/git-hooks/pre-commit
#!/bin/sh
npm run lint-staged
./sub-project2/git-hooks/pre-commit
#!/bin/sh
mvn antrun:run@ktlint-format
In the below example, if ./foo/bar/B is changed, pre-commit hooks are executed recursively in the following order:
./foo/bar/git-hooks/pre-commit./foo/git-hooks/pre-commit.
├── .git
│ └── hooks
│ └── pre-commit
└── foo
├── A
├── git-hooks
│ └── pre-commit
└── bar
├── B
└── git-hooks
└── pre-commit
git-hooks-dispatch searches a hook dir which name is hooks-dir or .hooks-dir by default. You can change it by --hooks-dir option.
git config core.hooksPath git-hooks
Setting RUST_LOG environment variable turns logging on.
RUST_LOG=debug git commit ...