Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
k-rister committed Sep 3, 2024
1 parent dae7b4d commit f32ab98
Showing 1 changed file with 29 additions and 27 deletions.
56 changes: 29 additions & 27 deletions crucible-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,8 @@ function update_repos_config() {
local current_repo_location primary_branch
local update_mode update_target
REPO=${1}
BRANCH=${2}
PATH=${3}
PATH=${2}
BRANCH=${3}

REPO_FILE=${PATH}/config/repos.json

Expand All @@ -297,32 +297,34 @@ function update_repos_config() {
jq_update ${REPO_FILE} repository --arg repository "${REPO}" '.official[] | select(.name == "crucible") |= (.repository = $repository)'
fi

primary_branch=$(jq_query ${REPO_FILE} '.official[] | select(.name == "crucible") | ."primary-branch"')
checkout_target=$(jq_query ${REPO_FILE} '.official[] | select(.name == "crucible") | .checkout.target')
checkout_mode=$(jq_query ${REPO_FILE} '.official[] | select(.name == "crucible") | .checkout.mode')
update_mode=0
update_target=0
if [ "${BRANCH}" == "${primary_branch}" ]; then
if [ "${BRANCH}" != "${checkout_target}" ]; then
update_target=1

# what do we do about the mode?
fi
else
if [ "${BRANCH}" == "${checkout_target}" ]; then
# no need to update the target, but what about the mode?
update_mode=0
if [ -n "${BRANCH}" ]; then
primary_branch=$(jq_query ${REPO_FILE} '.official[] | select(.name == "crucible") | ."primary-branch"')
checkout_target=$(jq_query ${REPO_FILE} '.official[] | select(.name == "crucible") | .checkout.target')
checkout_mode=$(jq_query ${REPO_FILE} '.official[] | select(.name == "crucible") | .checkout.mode')
update_mode=0
update_target=0
if [ "${BRANCH}" == "${primary_branch}" ]; then
if [ "${BRANCH}" != "${checkout_target}" ]; then
update_target=1

# what do we do about the mode?
fi
else
update_target=1

# what do we do about the mode?
if [ "${BRANCH}" == "${checkout_target}" ]; then
# no need to update the target, but what about the mode?
update_mode=0
else
update_target=1

# what do we do about the mode?
fi
fi
if [ ${update_mode} -eq 1 ]; then
jq_update ${REPO_FILE} checkout.mode --arg checkout_mode $MODE '.official[] | select(.name == "crucible") |= (.checkout.mode = $checkout_mode)'
fi
if [ ${update_target} -eq 1 ]; then
jq_update ${REPO_FILE} checkout.target --arg checkout_target $BRANCH '.official[] | select(.name == "crucible") |= (.checkout.target = $checkout_target)'
fi
fi
if [ ${update_mode} -eq 1 ]; then
jq_update ${REPO_FILE} checkout.mode --arg checkout_mode $MODE '.official[] | select(.name == "crucible") |= (.checkout.mode = $checkout_mode)'
fi
if [ ${update_target} -eq 1 ]; then
jq_update ${REPO_FILE} checkout.target --arg checkout_target $BRANCH '.official[] | select(.name == "crucible") |= (.checkout.target = $checkout_target)'
fi
set +x
}
Expand Down Expand Up @@ -461,7 +463,7 @@ echo "Using Git branch: ${GIT_BRANCH}"
git clone $GIT_REPO $INSTALL_PATH > $GIT_INSTALL_LOG 2>&1 ||
exit_error "Failed to git clone $GIT_REPO, check $GIT_INSTALL_LOG for details" $EC_FAIL_CLONE
source ${INSTALL_PATH}/bin/jqlib
update_repos_config ${GIT_REPO} ${GIT_BRANCH} ${INSTALL_PATH}
update_repos_config ${GIT_REPO} ${INSTALL_PATH} ${GIT_BRANCH}
if [ -n "${GIT_BRANCH}" ]; then
if pushd ${INSTALL_PATH} > /dev/null; then
git checkout ${GIT_BRANCH} >> $GIT_INSTALL_LOG 2>&1 ||
Expand Down

0 comments on commit f32ab98

Please sign in to comment.