herdsman 1.0.6 copy "herdsman: ^1.0.6" to clipboard
herdsman: ^1.0.6 copied to clipboard

Manage Git hooks in a centralized way. Analog husky in JS

Frame

πŸ‘ 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/githooks directory
  • πŸ”„ Copies existing Git hooks from .git/hooks
  • βš™οΈ Configures Git to use .herdsman/githooks as 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 .sample files
  • πŸ“„ 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 #

  1. Initialize herdsman:

    dart run herdsman --init
    
  2. Add a pre-commit hook:

    dart run herdsman --add pre-commit
    
  3. Activate all hooks:

    dart run herdsman --active
    
2
likes
160
points
585
downloads

Documentation

API reference

Publisher

verified publisherbangertstudio.kz

Weekly Downloads

Manage Git hooks in a centralized way. Analog husky in JS

Repository (GitHub)
View/report issues

Topics

#husky #git-hooks #git #cli

License

BSD-3-Clause (license)

Dependencies

args

More

Packages that depend on herdsman