hanzo

A library to easily use git hooks from Dart

Install

To start using Hanzo, add it to your dev_dependencies and run pub get

To install hooks in your project, run:

$ pub run hanzo install
    

Now create a matching git hook dart file in ./tool directory (create if needed).

Example:

    // in ./tool/pre_commit.dart
    main(List<String> arguments) => 
        print("I'll run before a commit is made!");

    // in ./tool/commit_msg.dart
    main(List<String> arguments) => 
        print("I'll run after commit message is entered!");

Install options

Option/Flagabbreviationdescription
--precommit-samplenoneIf flag is passed it will create a sample pre commit Dart script. Defaults to false
--hook <hook-name>-kCreates a bash script for the hook passed, supports passing multiple hooks. Defaults to all scripts. Example: -k pre-commit -k commit-message

Remove

To remove all hooks in your project, run:

$ pub run hanzo remove

Or if you want to remove a specific hook:

$ pub run hanzo remove -k pre-commit -k commit-msg

Git Hooks

Git hooks are scripts that run automatically every time a particular event occurs in a Git repository. Hanzo supports all git hooks (https://git-scm.com/docs/githooks)

Git hookDart script name
applypatch-msgapplypatch_msg.dart
commit-msgcommit_msg.dart
post-applypatchpost_applypatch.dart
post-checkoutpost_checkout.dart
post-commitpost_commit.dart
post-mergepost_merge.dart
post-receivepost_receive.dart
post-rewritepost_rewrite.dart
post-updatepost_update.dart
pre-applypatchpre_applypatch.dart
pre-auto-gcpre_auto_gc.dart
pre-commitpre_commit.dart
pre-pushpre_push.dart
pre-rebasepre_rebase.dart
pre-receivepre_receive.dart
prepare-commit-msgprepare_commit_msg.dart
push-to-checkoutpush_to_checkout.dart
updateupdate.dart

Accessing Git params

Git params will be passed as arguments to the main function of the Dart script.

Features and bugs

Please file feature requests and bugs at the issue tracker.

Libraries

hanzo