#git-hooks #git #manager #cli #monk

bin+lib monk

Monk is a simple Git hooks manager written in Rust. It allows you to manage and automate Git hooks easily using a YAML configuration file.

13 releases

new 0.2.1 Apr 16, 2025
0.2.0 Apr 16, 2025
0.1.10 Sep 23, 2024

#1565 in Command line utilities

MIT license

70KB
143 lines

Monk is a simple Git hooks manager

License GitHub Issues Crates.io

Monk's features:

  • 🦀 Easily set up in your Rust project. No need to install additional package managers.
  • ⚙️ Works with custom build.rs files. Automate the hooks installation process.
  • 💻 Run your hooks via CLI. Test your hooks without triggering them via Git.

Keep calm, monk will protect your repo!

Installation

You can install it using cargo:

cargo install monk

Or

You can just add it as a build dependency:

cargo add --build monk

And create build.rs file:

pub fn main() {
    monk::init();
}

In this case monk will be automatically installed and will init all hooks from monk.yaml.

This way is the most convenient way for rust projects since it doesn't require installing monk manually from all contributors.

Usage

Create a configuration file monk.yaml in your project:

pre-commit:
  commands:
    - cargo fmt -- --check
    - cargo clippy -- -D warnings

pre-push:
  commands:
    - cargo test

Then, install the hooks manually:

monk install

Or

Install monk as a build dependency (this is the preferred way):

cargo add --build monk

and create a build script build.rs:

pub fn main() {
    monk::init();
}

This way, monk will automatically install hooks for every team member during the build process.

Running hooks hooks manually

If you want to run specific hooks, use the run command:

monk run pre-commit

Dependencies

~2.7–3.5MB
~71K SLoC