Created
January 27, 2017 17:14
-
-
Save jamesnvc/5c4f2970df330252d29f95ce9cd26623 to your computer and use it in GitHub Desktop.
Shell script template to only act on "clean" git repos
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 | |
set -euo pipefail | |
set +e | |
if ! git diff-files --quiet --ignore-submodules ; then | |
echo "Uncommited changes; stash or commit before deploying" | |
exit 1 | |
fi | |
if ! git diff-index --cached --quiet HEAD --ignore-submodules ; then | |
echo "Staged but uncommited changes; commit before deploying" | |
exit 2 | |
fi | |
set -e | |
# do stuff |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment