From bc2a5655d8c435d7d0b0bc56c786eb0fa70a4e37 Mon Sep 17 00:00:00 2001 From: Brian Beck Date: Thu, 5 Oct 2017 20:48:51 -0700 Subject: [PATCH] Fix stash handling in deploy script --- scripts/deploy.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/deploy.sh b/scripts/deploy.sh index bab178b..2a992f7 100755 --- a/scripts/deploy.sh +++ b/scripts/deploy.sh @@ -7,7 +7,7 @@ RESET='\033[0m' # Fail if the `heroku` remote isn't there. git remote show heroku -git stash # Stash uncommitted changes. +STASH_OUTPUT=$(git stash) # Stash uncommitted changes. git checkout -B deploy # Force branch creation/reset. npm run build git add -f lib # Force add ignored files. @@ -17,6 +17,8 @@ git push -f heroku deploy:master git rm -r --cached lib # Otherwise switching branches will remove them. git checkout - # Switch back to whatever branch we came from. git branch -D deploy # Just to prevent someone accidentally pushing to GitHub. -git stash pop --index || true # Restore uncommitted changes, OK if none. +if [[ $STASH_OUTPUT != "No local changes"* ]]; then + git stash pop --index # Restore uncommitted changes. +fi echo -e "\n${GREEN}✔︎ Successfully deployed.${RESET}"