Git hook
Run commands automatically when using Git commands
Step 1: Create .githooks folder
.githooks foldermkdir -p .githooksStep 2: Create pre-push file
pre-push file.githooks/pre-push#!/usr/bin/env bash
# Flutter Analyzer
printf "\e[33;1m%s\e[0m\n" '=== Running Flutter analyzer ==='
# Undo the stash of the files
pop_stash_files () {
if [ -n "$hasChanges" ]; then
printf "\e[33;1m%s\e[0m\n" '=== Applying git stash changes ==='
git stash pop
fi
}
fvm flutter analyze
if [ $? -ne 0 ]; then
printf "\e[31;1m%s\e[0m\n" '=== Flutter analyzer error ==='
pop_stash_files
exit 1
fi
printf "\e[33;1m%s\e[0m\n" 'Finished running Flutter analyzer'Step 3: Activate Git hook
Combine with Make to group setup commands
MakeHow it works
How to disable
Update Git hook in project
Last updated