. ./.jprojects.sh || exit 255
-UNWANTED_NAME="stick"
+UNWANTED_NAME1="stick"
+UNWANTED_NAME2="jtrainings"
WANTED_NAME1="upstream"
WANTED_NAME2="daedalus"
WANTED_NAME3="transport"
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}")