This directory contains Git hooks for the flutter/packages repository.
To install all Git hooks, run the following commands from the root of the repository:
# Fetch dependencies for the githooks package dart pub get -C script/githooks # Run the installation script dart script/githooks/bin/install_hooks.dart
To only use specific Git hooks in this directory long-term, create a script in your local .git/hooks directory that runs the desired hook.
For example, to install only the pre-commit hook, create .git/hooks/pre-commit with:
#!/usr/bin/env bash exec dart script/githooks/bin/main.dart pre-commit "$@"
Then, make it executable and ensure Git uses your local .git/hooks directory:
chmod +x .git/hooks/pre-commit git config --unset core.hooksPath
If you installed all hooks using Option 1, you can uninstall them by running:
git config --unset core.hooksPath
If you manually added a specific Git hook (Option 2), you can uninstall it by deleting the script from your .git/hooks directory:
rm .git/hooks/pre-commit
To skip running hooks for a single action, pass the --no-verify flag. For example, to bypass the pre-commit hook during a commit:
git commit --no-verify
The pre-commit hook runs automatically when you run git commit and performs the following checks on any staged changes:
dart run script/tool/bin/flutter_plugin_tools.dart format --run-on-staged-packages to verify that all staged files in the targeted packages are correctly formatted.dart run script/tool/bin/flutter_plugin_tools.dart analyze --run-on-staged-packages --dart to run static analysis on the staged packages.If either check fails, it aborts the commit. To bypass the hook (for a WIP commit, for example), you can use the --no-verify flag:
git commit -m "WIP" --no-verify