Created
August 25, 2015 12:48
-
-
Save bensu/437c97a1ccf5f50fc5b3 to your computer and use it in GitHub Desktop.
CI for the Layman
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/sh | |
require_clean_work_tree () { | |
# Update the index | |
git update-index -q --ignore-submodules --refresh | |
err=0 | |
# Disallow unstaged changes in the working tree | |
if ! git diff-files --quiet --ignore-submodules -- | |
then | |
echo >&2 "cannot $1: you have unstaged changes." | |
git diff-files --name-status -r --ignore-submodules -- >&2 | |
err=1 | |
fi | |
# Disallow uncommitted changes in the index | |
if ! git diff-index --cached --quiet HEAD --ignore-submodules -- | |
then | |
echo >&2 "cannot $1: your index contains uncommitted changes." | |
git diff-index --cached --name-status -r --ignore-submodules HEAD -- >&2 | |
err=1 | |
fi | |
if [ $err = 1 ] | |
then | |
echo >&2 "Please commit or stash them." | |
exit 1 | |
fi | |
} | |
check_master () { | |
BRANCH=$(git rev-parse --abbrev-ref HEAD) | |
if [ "$BRANCH" != "master" ] | |
then | |
echo "You need to be in master to push" | |
exit 1 | |
fi | |
} | |
set -e | |
require_clean_work_tree | |
check_master | |
lein clean | |
lein test | |
lein doo slimer test once |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment