Skip to content

Instantly share code, notes, and snippets.

@rknell
Created December 17, 2019 23:03
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rknell/fecf9a84ccbc23a96e8be8bf60276265 to your computer and use it in GitHub Desktop.
Save rknell/fecf9a84ccbc23a96e8be8bf60276265 to your computer and use it in GitHub Desktop.
Flutter git precommit hook
#!/bin/sh
# To use add to `.git/hooks/`
# Should be named `pre-commit`
# Make executable with `chmod +x`
flutter analyze
flutter test
# Stash unstaged changes
git stash -q --keep-index
#Run flutter format
flutter format lib/ test/
# Stage updated files
git add -u
# Re-apply original unstaged changes
git stash pop -q
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment