builder: Fix checkouting repo on tag's branch when build from tag

This commit is contained in:
Arthur Golubtsov
2019-09-08 20:52:02 +03:00
parent 5326ed7dba
commit b32eaeb71d

View File

@@ -105,9 +105,13 @@ img-chroot ${IMAGE_PATH} exec ${SCRIPTS_DIR}'/image-configure.sh'
cd ${REPO_DIR}
git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
# Checkout to master if built with travis tag
# Checkout to tag's branch if built with travis tag
if [[ ! -z ${TRAVIS_TAG} ]]; then
git checkout $(git branch --contains ${TRAVIS_TAG} | sed -n 2p)
REMOTE_BRANCH="$(git branch -r --contains ${TRAVIS_TAG} | sed -n 1p | cut -d ' ' -f 5)"
BRANCH="$(echo ${REMOTE_BRANCH} | cut -d '/' -f 2)"
echo_stamp "Checkout to ${REMOTE_BRANCH} from ${TRAVIS_TAG}" "INFO"
git branch ${BRANCH} ${REMOTE_BRANCH}
git checkout ${BRANCH}
fi
# Copy service file for clever show client