Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix: Get rid of the subshell #7

Merged
merged 1 commit into from Feb 14, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
36 changes: 17 additions & 19 deletions files/r11k.sh
Expand Up @@ -232,26 +232,24 @@ function do_submodules_for_branch() {
let CHANGE_COUNTER+=1
new_branch='true'
fi
(
cd "${BASEDIR}/${branch_envname}"
git remote set-url origin "${MASTER_GIT_DIR}"
git remote update --prune
if [[ -z "$(git status --porcelain -uno)" ]] && [[ "$(git rev-parse HEAD)" = "$(git rev-parse "origin/${branch}")" ]] && [[ ${new_branch} == 'false' ]]
then
echo "${FONT_GREEN}Branch has no changes. ${FONT_NORMAL}${FONT_GREEN_BOLD}${branch}${FONT_NORMAL}"
else
echo "${FONT_GREEN}Branch is new or has changes! Updating. ${FONT_NORMAL}${FONT_GREEN_BOLD}${branch}${FONT_NORMAL}"
git fetch origin "$branch"
git reset --hard "origin/$branch"
git clean -ffdx
if ! do_submodules $branch; then
echo "${FONT_RED}Could not check out branch ${branch}, removing...${FONT_NORMAL}"
cd "${BASEDIR}"
rm -rf "${branch_envname}"
fi
let CHANGE_COUNTER+=1
cd "${BASEDIR}/${branch_envname}"
git remote set-url origin "${MASTER_GIT_DIR}"
git remote update --prune
if [[ -z "$(git status --porcelain -uno)" ]] && [[ "$(git rev-parse HEAD)" = "$(git rev-parse "origin/${branch}")" ]] && [[ ${new_branch} == 'false' ]]
then
echo "${FONT_GREEN}Branch has no changes. ${FONT_NORMAL}${FONT_GREEN_BOLD}${branch}${FONT_NORMAL}"
else
echo "${FONT_GREEN}Branch is new or has changes! Updating. ${FONT_NORMAL}${FONT_GREEN_BOLD}${branch}${FONT_NORMAL}"
git fetch origin "$branch"
git reset --hard "origin/$branch"
git clean -ffdx
if ! do_submodules $branch; then
echo "${FONT_RED}Could not check out branch ${branch}, removing...${FONT_NORMAL}"
cd "${BASEDIR}"
rm -rf "${branch_envname}"
fi
)
let CHANGE_COUNTER+=1
fi
}

function collect_branches() {
Expand Down