submodule-hook-0.1.0 is not a library.
Pre Commit Submodule Hook
This pre-commit hook asks you to confirm when submodules are either:
- modified and not staged for commit
- modified and staged for commit
It looks like this (YMMV) if you configure it as your pre-commit hook:
? The following submodules are modified but not staged for commit:
* sub2 (`git add sub2` to add submodule to staging)
The following submodules are modified and staged for commit:
* sub (`git restore --staged sub` to remove submodule from staging)
Do you wish to continue anyway? (y/n) › no
How to build it so that it runs with minimal dependencies (statically)
Build using musl
cargo build --target=x86_64-unknown-linux-musl
and then
❯ ldd target/x86_64-unknown-linux-musl/debug/submodule-hook
statically linked
How to install and configure it as my pre-commit hook ?
From source
- compile it:
cargo build --target=x86_64-unknown-linux-musl --release - install it as your
pre-commithook:cp target/x86_64-unknown-linux-musl/release/submodule-hook .git/hooks/pre-commit
From crates.io
- install it:
cargo install submodule-hook - install it as your
pre-commithook:cp $(which submodule-hook) .git/hooks/pre-commit
How to uninstall it ?
Remove the hook using: rm .git/hooks/pre-commit
If you installed it from crates.io, you can remove the binary from your ~/.cargo/bin directory using: cargo uninstall submodule-hook
Can I try it without setting it as my pre-commit hook ?
Yes, you can run it manually:
submodule-hook --repo <path-to-your-repo>
Configuration
Configuration is evaluated in this order:
- global
~/.gitconfig - local
.git/config - CLI parameters cf
cargo run -- --help - if no configuration is found it assumes
strict = false,staging = true,notstaging = true
Edit local .git/config or global ~/.gitconfig
[]
# if true the hook will fail when opening repository or submodule fails
= false
# if true also ask for confirmation before commit when a submodule is modified and staged
= true
# if true also ask for confirmation before commit when a submodule is modified and not staged
= true
if both
stagingandnotstagingare set tofalsethen the hook will be disabled
Or use git config:
git config submodulehook.strict false
git config submodulehook.staging true
git config submodulehook.notstaging true
CHANGELOG
Please see the CHANGELOG for a release history.