From 6a9668d7a8b84940a3241213296855f1d8e41ef0 Mon Sep 17 00:00:00 2001 From: Silvano Luciani Date: Wed, 3 Dec 2014 11:27:16 -0800 Subject: [PATCH] Avoid build failure if there is nothing new to push --- scripts/update_docs.sh | 21 +++++++++++++++------ scripts/update_wheels_project.sh | 17 +++++++++++++---- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/scripts/update_docs.sh b/scripts/update_docs.sh index fe431076d319..5ff3029d1875 100755 --- a/scripts/update_docs.sh +++ b/scripts/update_docs.sh @@ -23,10 +23,19 @@ git submodule add -b gh-pages \ ghpages cp -R docs/_build/html/* ghpages/ cd ghpages +# allow "git add" to fail if there aren't new files. +set +e git add . -# Commit to gh-pages branch to apply changes. -git config user.name "selfiebot" -git commit -m "Update docs after merge to master." -git push \ - "https://${GH_OAUTH_TOKEN}@github.com/${GH_OWNER}/${GH_PROJECT_NAME}" \ - HEAD:gh-pages +set -e +git status +# H/T: https://github.com/dhermes +if [[ -n "$(git status --porcelain)" ]]; then + # Commit to gh-pages branch to apply changes. + git config user.name "selfiebot" + git commit -m "Update docs after merge to master." + git push \ + "https://${GH_OAUTH_TOKEN}@github.com/${GH_OWNER}/${GH_PROJECT_NAME}" \ + HEAD:gh-pages +else + echo "Nothing to commit. Exiting without pushing changes." +fi diff --git a/scripts/update_wheels_project.sh b/scripts/update_wheels_project.sh index 78f3c00b516c..4068fc49ad3a 100755 --- a/scripts/update_wheels_project.sh +++ b/scripts/update_wheels_project.sh @@ -44,9 +44,18 @@ echo "${TRAVIS_COMMIT}" > ${FRESH_REPO_DIR}/LATEST_COMMIT # Display git status and push LATEST_COMMIT. # ############################################## cd ${FRESH_REPO_DIR} -git add LATEST_COMMIT +# allow "git add" to fail if there aren't new files. +# this can happen if we re-run builds on travis. +set +e +git add LATEST_COMMIT +set -e git status -git commit -m "Main project gcloud-python has been updated." -git status -git push origin master +# H/T: https://github.com/dhermes +if [[ -n "$(git status --porcelain)" ]]; then + git commit -m "Main project gcloud-python has been updated." + git status + git push origin master +else + echo "Nothing to commit. Exiting without pushing changes." +fi