build-hass/.pipeline/git-init.sh

39 lines
920 B
Bash
Executable File

#!/bin/bash
set -e
if [[ "${USE_GITHUB}" != "true" ]]; then
HASS_GIT_URL="https://git.sudo.is/home-assistant"
else
HASS_GIT_URL="https://github.com/home-assistant"
fi
HASS_MAIN_BRANCH="dev"
LOCAL_PATH=$(git rev-parse --show-toplevel)
if [[ ! -d "core/.git" ]]; then
echo "cloning '$HASS_GIT_URL/core'... "
git clone -q $HASS_GIT_URL/core
echo "done"
else
git -C core/ checkout .
git -C core/ clean -fd
CURRENT_BRANCH=$(git -C core/ rev-parse --abbrev-ref HEAD)
if [[ "$CURRENT_BRANCH" != "${HASS_MAIN_BRANCH}" ]]; then
git -C core/ checkout $HASS_MAIN_BRANCH
fi
git -C core/ remote rm origin || true
git -C core/ remote add origin $HASS_GIT_URL/core
git -C core/ pull origin $HASS_MAIN_BRANCH
fi
echo
echo "HASS remote: '$HASS_GIT_URL/core'"
echo "HASS local: '$LOCAL_PATH/core'"
echo "HASS branch: '$(git -C core/ rev-parse --abbrev-ref HEAD)'"
echo