diff --git a/is-clean.sh b/is-clean.sh index 83956e5c9..b63b54f46 100755 --- a/is-clean.sh +++ b/is-clean.sh @@ -1,6 +1,21 @@ #!/usr/bin/env bash -if ! ( output=$(git status --porcelain) && [ -z "$output" ] ); then +set -e + +if [ -n "$(git status --porcelain)" ]; then echo "Working directory isn't clean" >&2 exit 1 fi + +if [ "$(git rev-parse --abbrev-ref HEAD)" != "master" ]; then + echo "Not on master" >&2 + exit 1 +fi + +ourHash=$(git rev-parse HEAD) +theirHash=$(git ls-remote origin -h refs/heads/master | awk '{ print $1; }') + +if [ "$theirHash" != "$ourHash" ]; then + echo "Local HEAD is not up to date with remote master" >&2 + exit 1 +fi