Skip to content
pubscout

git_hooks

1.0.2, released 2 years ago by an unverified publisher

Prevent bad git commit or push using Dart and Flutter, similar to Husky.

$ flutter pub add git_hooks
Source repository

What it does

It allows developers to set up git hooks using Dart code to run checks like tests or static analysis before a commit or push is made. If the script returns false, the git operation is interrupted.

AI-written summary of version 1.0.2, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You want to enforce pre-commit static analysis or code formatting in Dart/Flutter projects
  • You prefer writing your git hooks in Dart instead of shell scripts

Skip it when

  • Your project does not use Dart or Flutter
  • You prefer traditional native shell-based git hooks

Strengths

  • Write git hooks using familiar Dart code
  • Supports a wide range of git hooks via an enum
  • Easy initialization using shell commands or Dart code

Weaknesses

  • Relies on Dart environment setup for git hooks execution

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
3

Add to dev_dependencies, run pub get, and initialize via the CLI tool or Dart code.

import "package:git_hooks/git_hooks.dart";
import "dart:io";

void main(List arguments) {
  Map<Git, UserBackFun> params = {
    Git.commitMsg: commitMsg,
    Git.preCommit: preCommit
  };
  GitHooks.call(arguments, params);
}

Future<bool> commitMsg() async {
  String commitMsg = Utils.getCommitEditMsg();
  if (commitMsg.startsWith('fix:')) {
    return true;
  } else
    return false;
}

Alternatives

Packages that do the same job and could replace git_hooks.

Works with

Packages commonly used together with git_hooks: ones it builds on, ones built on it, and its own family.