Skip to content

Instantly share code, notes, and snippets.

@Gperez88
Forked from miquelbeltran/pre-push
Created December 29, 2019 20:38
Show Gist options
  • Save Gperez88/38c664ef16b995f4c23222a6432cece4 to your computer and use it in GitHub Desktop.
Save Gperez88/38c664ef16b995f4c23222a6432cece4 to your computer and use it in GitHub Desktop.
Flutter pre-push hook that runs analyze and test
#!/bin/sh
# To use add to `.git/hooks/`
# Should be named `pre-push`
# Make executable with `chmod +x`
# stash any unstaged changes
git stash -q --keep-index
# run Flutter analyze + test
flutter analyze
if [ $? -ne 0 ]; then
# unstash the unstashed changes
git stash pop -q
exit 1
fi
flutter test
if [ $? -ne 0 ]; then
# unstash the unstashed changes
git stash pop -q
exit 1
fi
# unstash the unstashed changes
git stash pop -q
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment