@ -56,13 +56,11 @@ declare -A COLOR_STRINGS=(
# $1 - module folder
# $1 - module folder
# $2 - operation type
# $2 - operation type
# $3 - branch to update
# $3 - branch to update
# $4 - new branch flag (only for reporting)
function _do_update( )
function _do_update( )
{
{
local MOD_PATH = $1
local MOD_PATH = $1
local OP_TYPE = $2
local OP_TYPE = $2
local BRANCH = $3
local BRANCH = $3
local NEW_BRANCH = $4
local RESULT = ""
local RESULT = ""
local LINE_CTRL_SUFFIX = ""
local LINE_CTRL_SUFFIX = ""
@ -93,14 +91,12 @@ function _do_update()
fi
fi
# Make sure the local branch exists
# Make sure the local branch exists
if [ [ -z ` git branch | grep -E " \b $BRANCH \b " ` ] ] ; then
if [ [ -z ` git branch | grep -E " \b $BRANCH \b " ` ] ] ; then
NEW_BRANCH = "y"
eval git checkout -b \" $BRANCH \" \" origin/$BRANCH \" $OPT_VERBOSE_LOG
eval git checkout -b \" $BRANCH \" \" origin/$BRANCH \" $OPT_VERBOSE_LOG
else
else
eval git checkout \" $BRANCH \" $OPT_VERBOSE_LOG
eval git checkout \" $BRANCH \" $OPT_VERBOSE_LOG
fi
fi
# Make sure the local branch is a tracking branch
# Make sure the local branch is a tracking branch
if [ [ -z ` git config branch." $BRANCH " .remote` ] ] ; then
if [ [ -z ` git config branch." $BRANCH " .remote` ] ] ; then
NEW_BRANCH = "y"
git branch -u " origin/ $BRANCH " & >/dev/null #$
git branch -u " origin/ $BRANCH " & >/dev/null #$
git reset --hard " origin/ $BRANCH " & >/dev/null
git reset --hard " origin/ $BRANCH " & >/dev/null
fi
fi
@ -115,11 +111,7 @@ function _do_update()
RESULT = "FAIL"
RESULT = "FAIL"
fi
fi
else
else
if [ [ " $NEW_BRANCH " = "y" ] ] ; then
RESULT = "OK"
RESULT = "UPDATE"
else
RESULT = "OK"
fi
fi
fi
else
else
RESULT = "FAIL"
RESULT = "FAIL"
@ -156,7 +148,6 @@ function _do_update()
# $1 - module folder
# $1 - module folder
# $2 - operation type
# $2 - operation type
# $3 - branch to update
# $3 - branch to update
# $4 - new branch flag (only for reporting)
function _update_module( )
function _update_module( )
{
{
local MOD_PATH = $1
local MOD_PATH = $1
@ -166,22 +157,18 @@ function _update_module()
# Current module
# Current module
_do_update " $@ "
_do_update " $@ "
# Submodules
# Submodules
local NEW_BRANCH = "n"
local SUBMOD_LIST = " $MOD_PATH /.gitmodules "
local SUBMOD_LIST = " $MOD_PATH /.gitmodules "
if [ [ -e " $SUBMOD_LIST " ] ] ; then
if [ [ -e " $SUBMOD_LIST " ] ] ; then
sed -n " s|^\[submodule \"\([^\"]*\)\"\] $|\1|p " <$SUBMOD_LIST | \
sed -n " s|^\[submodule \"\([^\"]*\)\"\] $|\1|p " <$SUBMOD_LIST | \
while read -r SUBMOD_PATH; do
while read -r SUBMOD_PATH; do
NEW_BRANCH = "n"
cd " $MOD_PATH " & >/dev/null
cd " $MOD_PATH " & >/dev/null
if [ [ -z " `git config --get submodule. $SUBMOD_PATH .url` " ] ] ; then
if [ [ -z " `git config --get submodule. $SUBMOD_PATH .url` " ] ] ; then
NEW_BRANCH = "y" # if a submodule is missing, need to report "update" status
eval git submodule init -- \" $SUBMOD_PATH \" $OPT_VERBOSE_LOG
eval git submodule init -- \" $SUBMOD_PATH \" $OPT_VERBOSE_LOG
fi
fi
if [ [ ! -e " $MOD_PATH / $SUBMOD_PATH /.git " ] ] ; then
if [ [ ! -e " $MOD_PATH / $SUBMOD_PATH /.git " ] ] ; then
NEW_BRANCH = "y" # if a submodule is incomplete, need to report "update" status
eval git submodule update -- \" $SUBMOD_PATH \" $OPT_VERBOSE_LOG
eval git submodule update -- \" $SUBMOD_PATH \" $OPT_VERBOSE_LOG
fi
fi
_update_module " $MOD_PATH / $SUBMOD_PATH " " $OP_TYPE " " $BRANCH " " $NEW_BRANCH "
_update_module " $MOD_PATH / $SUBMOD_PATH " " $OP_TYPE " " $BRANCH "
done
done
fi
fi
}
}
@ -238,10 +225,10 @@ if [[ "$flag_SWITCH_ONLY" != "y" ]]; then
echo_and_tee " ${ CLightCyan } --------------------------------------- ${ CNone } " " $LOG_UPDATE_REPO_FILENAME "
echo_and_tee " ${ CLightCyan } --------------------------------------- ${ CNone } " " $LOG_UPDATE_REPO_FILENAME "
# Update TDE main repository
# Update TDE main repository
_update_module " $REPO_TDE " "update" " $branch " "n"
_update_module " $REPO_TDE " "update" " $branch "
# Update TDE packaging repository
# Update TDE packaging repository
_update_module " $TDE_DIR / $CFG_GIT_DIR /tde-packaging " "update" " $branch " "n"
_update_module " $TDE_DIR / $CFG_GIT_DIR /tde-packaging " "update" " $branch "
echo -e "\033[2K"
echo -e "\033[2K"
echo "" >> " $LOG_UPDATE_REPO_FILENAME "
echo "" >> " $LOG_UPDATE_REPO_FILENAME "
@ -255,10 +242,10 @@ if [[ "$DEFAULT_REPO_BRANCH" != "$_LAST_BRANCH" ]]; then
echo_and_tee " ${ CLightCyan } --------------------------------------- ${ CNone } " " $LOG_UPDATE_REPO_FILENAME "
echo_and_tee " ${ CLightCyan } --------------------------------------- ${ CNone } " " $LOG_UPDATE_REPO_FILENAME "
# Switch TDE main repository
# Switch TDE main repository
_update_module " $REPO_TDE " "switch-to" " $DEFAULT_REPO_BRANCH " "n"
_update_module " $REPO_TDE " "switch-to" " $DEFAULT_REPO_BRANCH "
# Switch TDE packaging repository
# Switch TDE packaging repository
_update_module " $TDE_DIR / $CFG_GIT_DIR /tde-packaging " "switch-to" " $DEFAULT_REPO_BRANCH " "n"
_update_module " $TDE_DIR / $CFG_GIT_DIR /tde-packaging " "switch-to" " $DEFAULT_REPO_BRANCH "
echo -e "\033[2K"
echo -e "\033[2K"
echo "" >> " $LOG_UPDATE_REPO_FILENAME "
echo "" >> " $LOG_UPDATE_REPO_FILENAME "