herdsman 1.0.6
herdsman: ^1.0.6 copied to clipboard
Manage Git hooks in a centralized way. Analog husky in JS

π 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 #
In a project (as dev dependency) #
dart pub add -d herdsman
Or manually in pubspec.yaml:
dev_dependencies:
herdsman: ^1.0.2
Globally #
dart pub global activate herdsman
Then run as:
herdsman [flags] [arguments]
π Usage #
dart run herdsman [flags] [arguments]
Available Flags #
| Flag | Description |
|---|---|
-h, --help |
Print usage information |
-v, --verbose |
Show additional command output |
-i, --init |
Initialize git hooks directory structure |
-A, --active |
Activate herdsman added git hooks |
-a, --add |
Add git hooks |
-d, --delete |
Delete git hooks |
--version |
Print the tool version |
π― Commands #
Initialize Git Hooks #
Initialize the .herdsman/githooks directory and configure Git to use it:
dart run herdsman --init
With verbose output:
dart run herdsman --init -verbose
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
Add Git Hooks #
Add Git hooks:
dart run herdsman --add <hook-name>
Example:
dart run herdsman --add pre-commit pre-merge
What it does:
- π¨ Creates git hook files
- βοΈ Writes shebang and error handling
- π Creates the hook file
- β οΈ Skips if hook already exists
- β Activates the hook
Activate Git Hooks #
Activate all existing Git hooks in the herdsman directory:
dart run herdsman --active
What it does:
- βοΈ Configures Git hooks path
- β Makes all hook files executable
- π Confirms when all hooks are activated
Delete Git Hooks #
Delete specific Git hooks:
dart run herdsman --delete <hook-name>
Example:
dart run herdsman --delete pre-commit pre-push
What it does:
- ποΈ Converts active hooks to
.samplefiles - π Preserves hook content for later use
- π Prevents the hook from executing
π Directory Structure #
After initialization, your repository will have:
.herdsman/
βββ githooks/
βββ pre-commit # Active hook
βββ pre-push
βββ commit-msg.sample # Sample hook (not active)
βββ ... (other hooks)
π‘ Examples #
Complete Setup Workflow #
-
Initialize herdsman:
dart run herdsman --init -
Add a pre-commit hook:
dart run herdsman --add pre-commit -
Activate all hooks:
dart run herdsman --active