Skip to content

Instantly share code, notes, and snippets.

@samuelematias
Forked from rogood/pre-push
Created July 7, 2020 01:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samuelematias/6c21b19f365049e31b46b54ca5b04c8b to your computer and use it in GitHub Desktop.
Save samuelematias/6c21b19f365049e31b46b54ca5b04c8b to your computer and use it in GitHub Desktop.
Flutter Pre Push Hook with Console Messages
#!/usr/bin/env bash
if [[ `git status --porcelain` ]]; then
printf "\e[31;1m%s\e[0m\n" 'This script needs to run against committed code only. Please commit or stash you changes.'
exit 1
fi
printf "\e[33;1m%s\e[0m\n" 'Running the Flutter analyzer'
flutter analyze
if [ $? -ne 0 ]; then
printf "\e[31;1m%s\e[0m\n" 'Flutter analyzer error'
exit 1
fi
printf "\e[33;1m%s\e[0m\n" 'Finished running the Flutter analyzer'
printf "\e[33;1m%s\e[0m\n" 'Running unit tests'
flutter test
if [ $? -ne 0 ]; then
printf "\e[31;1m%s\e[0m\n" 'Unit tests error'
exit 1
fi
printf "\e[33;1m%s\e[0m\n" 'Finished running unit tests'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment