From 10cd654ff58092f66080c36fbba781ddb6f47976 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Fri, 11 Sep 2015 15:41:44 +1000 Subject: [PATCH] CI Handling git tags Buildkite is running tags like branches. This caused `git branch` commands to fail. The function got extended to handle tags as well. Ideally, Buildkite will offer an option not to rebuild tags. --- script/ci/includes.sh | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/script/ci/includes.sh b/script/ci/includes.sh index a0599504c2..619d03153e 100644 --- a/script/ci/includes.sh +++ b/script/ci/includes.sh @@ -5,18 +5,33 @@ function load_environment { fi } +function master_merged { + if [[ `git tag -l "$BUILDKITE_BRANCH"` != '' ]]; then + echo "'$BUILDKITE_BRANCH' is a tag." + if [[ `git tag -l --contains origin/master "$BUILDKITE_BRANCH"` != '' ]]; then + echo "This tag contains the current master." + return 0 + else + echo "This tag does not contain the current master." + return 1 + fi + fi + if [[ `git branch -r --merged origin/$BUILDKITE_BRANCH` == *origin/master* ]]; then + echo "This branch already has the current master merged." + return 0 + fi + return 1 +} + function exit_unless_master_merged { - if [[ `git branch -a --merged origin/$BUILDKITE_BRANCH` != *origin/master* ]]; then + if ! master_merged; then echo "This branch does not have the current master merged. Please merge master and push again." exit 1 fi } function succeed_if_master_merged { - if [[ `git branch -a --merged origin/$BUILDKITE_BRANCH` == *origin/master* ]]; then - echo "This branch already has the current master merged." - exit 0 - fi + master_merged && exit 0 } function set_ofn_commit {