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.
This commit is contained in:
Maikel Linke
2015-09-11 15:41:44 +10:00
parent 51064f31a3
commit 10cd654ff5

View File

@@ -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 {