π Herdsman
A Dart command-line tool for managing Git hooks in your repository. Herdsman simplifies the process of initializing, applying, and activating Git hooks by organizing them in a dedicated .herdsman/githooks directory.
π Features
- π Initialize Git hooks directory structure
- π¨ Apply custom Git hooks from samples
- β Activate and make hooks executable
- π― Verbose mode for detailed operation logs
- π Easy hook management and organization
π Installation
Add herdsman to your project:
dev_dependencies:
herdsman: version
or command
dart pub add herdsman
π Usage
dart run herdsman [flags] [arguments]
Available Flags
| Flag | Description |
|---|---|
-h, --help |
Print usage information |
-v, --verbose |
Show additional command output with emoji indicators |
-i, --init |
Initialize git hooks directory structure |
-c, --active |
Activate herdsman git hooks |
-a, --apply |
Apply git hooks from samples |
--version |
Print the tool version |
π― Commands
Initialize Git Hooks
Initialize the .herdsman/githooks directory and configure Git to use it:
dart run herdsman -i
With verbose output:
dart run herdsman -i -v
What it does:
- π Creates
.herdsman/githooksdirectory - π Copies existing Git hooks from
.git/hooks - βοΈ Configures Git to use
.herdsman/githooksas hooks path - β Validates that you're in a Git repository
Apply Git Hooks
Apply Git hooks from sample files:
dart run herdsman -a <hook-name>
Example:
dart run herdsman -a pre-commit pre-merge
With verbose output:
dart run herdsman -a pre-commit -v
What it does:
- π¨ Creates git hook from
.samplefile - βοΈ Writes shebang and error handling
- π Creates the hook file
- ποΈ Removes the sample file
- β οΈ Skips if hook already exists
- β Active hook
Activate applies Git Hooks
Activate all existing Git hooks in the herdsman directory:
dart run herdsman -c
With verbose output:
dart run herdsman -c -v
What it does:
- βοΈ Configures Git hooks path
- β Makes all hook files executable
- π Confirms when all hooks are activated
π Directory Structure
After initialization, your repository will have:
.herdsman/
βββ githooks/
βββ pre-commit
βββ pre-push
βββ commit-msg
βββ ... (other hooks)
π‘ Examples
Complete Setup Workflow
-
Initialize herdsman:
dart run herdsman -i -v -
Apply a pre-commit hook:
dart run herdsman -a pre-commit -v -
Activate all hooks:
dart run herdsman -c -v
Quick Setup
Initialize and activate in one go:
dart run herdsman -i