From 43df930fba896615c7a9fcf9bc17e6d90989cee2 Mon Sep 17 00:00:00 2001 From: Maruan Al-Shedivat Date: Tue, 26 Sep 2017 10:16:08 -0400 Subject: [PATCH] Ensure everything is committed before deploying --- bin/deploy | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/bin/deploy b/bin/deploy index b4f0d7f..368633a 100755 --- a/bin/deploy +++ b/bin/deploy @@ -46,6 +46,22 @@ echo "Deploying..." echo "Source branch: $SRC_BRANCH" echo "Deploy branch: $DEPLOY_BRANCH" +read -r -p "Do you want to proceed? [y/N] " response +if [[ ! $response =~ ^([yY][eE][sS]|[yY])+$ ]] +then + echo "Aborting." + [[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1 +fi + +# Check if there are any uncommitted changes +if ! git diff-index --quiet HEAD --; then + echo "Changes to the following files are uncommitted:" + git diff-index --name-only HEAD -- + echo "Please commit the changes before proceeding." + echo "Aborting." + [[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1 +fi + # Switch to source branch (creates it if necessary from the current branch) if [ `git branch | grep $SRC_BRANCH | tr ' ' '\n' | tail -1` ] then