Created
April 20, 2020 14:37
-
-
Save ampersanda/6dcac705ef614b3b7be85be90f9f2dd1 to your computer and use it in GitHub Desktop.
Dart analysis_options.yaml pre-push guard
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Run to initialze pre-push configuration | |
rm -f .git/hooks/pre-push | |
cat >.git/hooks/pre-push <<EOL | |
# stash any unstaged changes | |
git stash -q --keep-index | |
# run Flutter analyze | |
if ! type "$PWD/fvm" > /dev/null; then | |
echo 'Using flutter' | |
flutter analyze | |
else | |
echo 'Using fvm' | |
./fvm analyze | |
fi | |
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 | |
EOL | |
chmod +x .git/hooks/pre-push |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment