From 6b65437452d4c8a6434a855d418b258743333988 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Wed, 15 Jan 2020 00:24:04 +0100 Subject: [PATCH] Continued: - jtrainings is no longer wanted, let's remove it then. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- fix-project-remotes.sh | 82 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 76 insertions(+), 6 deletions(-) diff --git a/fix-project-remotes.sh b/fix-project-remotes.sh index 773330d..e8b6ec3 100755 --- a/fix-project-remotes.sh +++ b/fix-project-remotes.sh @@ -2,7 +2,8 @@ . ./.jprojects.sh || exit 255 -UNWANTED_NAME="stick" +UNWANTED_NAME1="stick" +UNWANTED_NAME2="jtrainings" WANTED_NAME1="upstream" WANTED_NAME2="daedalus" WANTED_NAME3="transport" @@ -152,26 +153,95 @@ for project in ${LIST}; do fi fi - UNWANTED_REMOTE=$(git remote | grep "${UNWANTED_NAME}") + UNWANTED_REMOTE=$(git remote | grep "${UNWANTED_NAME1}") echo "$0: UNWANTED_REMOTE='${UNWANTED_REMOTE}'" if [ -n "${UNWANTED_REMOTE}" ] then - echo "$0: Found remote '${UNWANTED_NAME}' in '${project}'. Renaming '${GIT_ORIGIN}'->'${WANTED_NAME1}' and '${UNWANTED_NAME}'->'${GIT_ORIGIN}' ..." + echo "$0: Found remote '${UNWANTED_NAME1}' in '${project}'. Renaming '${GIT_ORIGIN}'->'${WANTED_NAME1}' and '${UNWANTED_NAME1}'->'${GIT_ORIGIN}' ..." UPSTREAM_REMOTE=$(git remote | grep "${WANTED_NAME1}") echo "$0: UPSTREAM_REMOTE='${UPSTREAM_REMOTE}'" if [ -n "${UPSTREAM_REMOTE}" ] then - echo "$0: Remotes '${UNWANTED_NAME}' and '${WANTED_NAME1}' exist! Removing '${WANTED_NAME1}' ..." + echo "$0: Remotes '${UNWANTED_NAME1}' and '${WANTED_NAME1}' exist! Removing '${WANTED_NAME1}' ..." git remote rm "${WANTED_NAME1}" || exit 255 fi git remote rename "${GIT_ORIGIN}" "${WANTED_NAME1}" || exit 255 - git remote rename "${UNWANTED_NAME}" "${GIT_ORIGIN}" || exit 255 + git remote rename "${UNWANTED_NAME1}" "${GIT_ORIGIN}" || exit 255 else - echo "$0: No unwanted '${UNWANTED_NAME}' remote in '${project}' ..." + echo "$0: No unwanted '${UNWANTED_NAME1}' remote in '${project}' ..." + UPSTREAM_REMOTE1=$(git remote | grep "${WANTED_NAME1}") + UPSTREAM_REMOTE2=$(git remote | grep "${WANTED_NAME2}") + UPSTREAM_REMOTE3=$(git remote | grep "${WANTED_NAME3}") + UPSTREAM_REMOTE4=$(git remote | grep "${WANTED_NAME4}") + echo "$0: UPSTREAM_REMOTE1='${UPSTREAM_REMOTE1}',UPSTREAM_REMOTE2='${UPSTREAM_REMOTE2}',UPSTREAM_REMOTE3='${UPSTREAM_REMOTE3},UPSTREAM_REMOTE4='${UPSTREAM_REMOTE4}'" + + if [ -n "${UPSTREAM_REMOTE1}" ] + then + echo "$0: Wanted remote '${WANTED_NAME1}' already found in '${project}'." + else + echo "$0: No wanted '${WANTED_NAME1}' in '${project}'. Adding ..." + git remote add "${WANTED_NAME1}" "${GIT_URL1}" --track "${GIT_BRANCH}" || exit 255 + fi + + if [ -n "${UPSTREAM_REMOTE2}" ] + then + echo "$0: Remote '${WANTED_NAME2}' found in '${project}'." + elif [ ! -d "${GIT_URL2}" ] + then + echo "$0: Remote '${WANTED_NAME2}' cannot be created, path '${GIT_URL2}' missing." + elif [ -n "${WANTED_NAME2}" ] + then + echo "$0: No wanted '${WANTED_NAME2}' in '${project}'. Adding ..." + git remote add "${WANTED_NAME2}" "${GIT_URL2}" --track "${GIT_BRANCH}" || exit 255 + fi + + if [ -n "${UPSTREAM_REMOTE3}" ] + then + echo "$0: Remote '${WANTED_NAME3}' found in '${project}'." + elif [ ! -d "${GIT_URL3}" ] + then + echo "$0: Remote '${WANTED_NAME3}' cannot be created, path '${GIT_URL3}' missing." + else + echo "$0: No wanted '${WANTED_NAME3}' in '${project}'. Adding ..." + git remote add "${WANTED_NAME3}" "${GIT_URL3}" --track "${GIT_BRANCH}" || exit 255 + fi + + if [ -n "${UPSTREAM_REMOTE4}" ] + then + echo "$0: Remote '${WANTED_NAME4}' found in '${project}'." + elif [ ! -d "${GIT_URL4}" ] + then + echo "$0: Remote '${WANTED_NAME4}' cannot be created, path '${GIT_URL4}' missing." + else + echo "$0: No wanted '${WANTED_NAME4}' in '${project}'. Adding ..." + git remote add "${WANTED_NAME4}" "${GIT_URL4}" --track "${GIT_BRANCH}" || exit 255 + fi + fi + + UNWANTED_REMOTE=$(git remote | grep "${UNWANTED_NAME2}") + echo "$0: UNWANTED_REMOTE='${UNWANTED_REMOTE}'" + + if [ -n "${UNWANTED_REMOTE}" ] + then + echo "$0: Found remote '${UNWANTED_NAME2}' in '${project}'. Renaming '${GIT_ORIGIN}'->'${WANTED_NAME1}' and '${UNWANTED_NAME2}'->'${GIT_ORIGIN}' ..." + + UPSTREAM_REMOTE=$(git remote | grep "${WANTED_NAME1}") + echo "$0: UPSTREAM_REMOTE='${UPSTREAM_REMOTE}'" + + if [ -n "${UPSTREAM_REMOTE}" ] + then + echo "$0: Remotes '${UNWANTED_NAME2}' and '${WANTED_NAME1}' exist! Removing '${WANTED_NAME1}' ..." + git remote rm "${WANTED_NAME1}" || exit 255 + fi + + git remote rename "${GIT_ORIGIN}" "${WANTED_NAME1}" || exit 255 + git remote rename "${UNWANTED_NAME2}" "${GIT_ORIGIN}" || exit 255 + else + echo "$0: No unwanted '${UNWANTED_NAME2}' remote in '${project}' ..." UPSTREAM_REMOTE1=$(git remote | grep "${WANTED_NAME1}") UPSTREAM_REMOTE2=$(git remote | grep "${WANTED_NAME2}") UPSTREAM_REMOTE3=$(git remote | grep "${WANTED_NAME3}") -- 2.39.5