From 1363daae3c2ea9c4e2baa33162e8683ea7e20675 Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Fri, 26 Jun 2015 11:22:19 +1000 Subject: [PATCH] When fetching ofn commit, if it is not found, return a sentinal value to avoid a wayward git push --- script/ci/includes.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/script/ci/includes.sh b/script/ci/includes.sh index 497959d33b..a0599504c2 100644 --- a/script/ci/includes.sh +++ b/script/ci/includes.sh @@ -25,7 +25,17 @@ function set_ofn_commit { } function get_ofn_commit { - echo `buildkite-agent meta-data get "openfoodnetwork:git:commit"` + OFN_COMMIT=`buildkite-agent meta-data get "openfoodnetwork:git:commit"` + + # If we don't catch this failure case, push will execute: + # git push remote :master --force + # Which will delete the master branch on the server + + if [[ `expr length "$OFN_COMMIT"` == 0 ]]; then + echo 'OFN_COMMIT_NOT_FOUND' + else + echo $OFN_COMMIT + fi } function checkout_ofn_commit {