fi
echo "$0: project='${project}'"
+ cd "${JPROJECTS_HOME}/${project}" || exit 255
GIT_URL1="${GIT_USER}@${GIT_SERVER}:${GIT_PATH}/${project}.git"
GIT_URL2="${GIT_PATH}/${project}.git"
GIT_URL4="file:///E:/Java%20Project/${project}.git"
GIT_URL5="E:/Java Project/${project}.git"
GIT_URL6="${MEDIA_BASE}/${USER}/${MEDIA_NAME1}/${MEDIA_PATH}/${project}.git"
- echo "$0: GIT_URL1='${GIT_URL1}',GIT_URL2='${GIT_URL2}',GIT_URL3='${GIT_URL3}',GIT_URL4='${GIT_URL4}',GIT_URL5='${GIT_URL5}',GIT_URL6='${GIT_URL6}'"
-
- cd "${JPROJECTS_HOME}/${project}" || exit 255
+ echo "$0: GIT_URL1='${GIT_URL1}'"
+ echo "$0: GIT_URL2='${GIT_URL2}'"
+ echo "$0: GIT_URL3='${GIT_URL3}'"
+ echo "$0: GIT_URL4='${GIT_URL4}'"
+ echo "$0: GIT_URL5='${GIT_URL5}'"
+ echo "$0: GIT_URL6='${GIT_URL6}'"
if [ "$1" = "l" ]
then
continue
fi
- REMOTES=`git remote | wc -l`
+ REMOTES=$(git remote | wc -l)
echo "$0: REMOTES='${REMOTES}'"
if [ "${REMOTES}" = "0" ]
then
echo "$0: Only one remote found for '${project}'"
- REMOTE=`git remote`
- REMOTE_PUSH=`git remote -v | grep "push"`
+ REMOTE=$(git remote)
+ REMOTE_PUSH=$(git remote -v | grep "push")
echo "$0: REMOTE='${REMOTE}',REMOTE_PUSH='${REMOTE_PUSH}'"
- MEDIA1=`echo "${REMOTE_PUSH}" | grep "${MEDIA_BASE}/${USER}/${MEDIA_NAME1}/"`
+ MEDIA1=$(echo "${REMOTE_PUSH}" | grep "${MEDIA_BASE}/${USER}/${MEDIA_NAME1}/")
echo "$0: MEDIA1='${MEDIA1}'"
if [ -n "${MEDIA1}" ]
fi
else
echo "$0: Not a media remote."
- MXCHANGE_REMOTE=`echo "${REMOTE_PUSH}" | grep "${GIT_URL1}"`
- LINUX_MEDIA_PATH_REMOTE=`echo "${REMOTE_PUSH}" | grep "${GIT_URL3}"`
- WINDOWS_FILE_REMOTE=`echo "${REMOTE_PUSH}" | grep "${GIT_URL4}"`
- WINDOWS_PATH_REMOTE=`echo "${REMOTE_PUSH}" | grep "${GIT_URL5}"`
+ MXCHANGE_REMOTE=$(echo "${REMOTE_PUSH}" | grep "${GIT_URL1}")
+ LINUX_MEDIA_PATH_REMOTE=$(echo "${REMOTE_PUSH}" | grep "${GIT_URL3}")
+ WINDOWS_FILE_REMOTE=$(echo "${REMOTE_PUSH}" | grep "${GIT_URL4}")
+ WINDOWS_PATH_REMOTE=$(echo "${REMOTE_PUSH}" | grep "${GIT_URL5}")
echo "$0: MXCHANGE_REMOTE='${MXCHANGE_REMOTE}',WINDOWS_FILE_REMOTE='${WINDOWS_FILE_REMOTE}',WINDOWS_PATH_REMOTE='${WINDOWS_PATH_REMOTE}',LINUX_MEDIA_PATH_REMOTE='${LINUX_MEDIA_PATH_REMOTE}'"
if [ -n "${MXCHANGE_REMOTE}" ]
fi
fi
- UNWANTED_REMOTE=`git remote | grep "${UNWANTED_NAME}"`
+ UNWANTED_REMOTE=$(git remote | grep "${UNWANTED_NAME}")
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}' ..."
- UPSTREAM_REMOTE=`git remote | grep "${WANTED_NAME1}"`
+ UPSTREAM_REMOTE=$(git remote | grep "${WANTED_NAME1}")
echo "$0: UPSTREAM_REMOTE='${UPSTREAM_REMOTE}'"
if [ -n "${UPSTREAM_REMOTE}" ]
git remote rename "${UNWANTED_NAME}" "${GIT_ORIGIN}" || exit 255
else
echo "$0: No unwanted '${UNWANTED_NAME}' 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_REMOTE1=$(git remote | grep "${WANTED_NAME1}")
+ UPSTREAM_REMOTE2=$(git remote | grep "${WANTED_NAME2}")
+ UPSTREAM_REMOTE3=$(git remote | grep "${WANTED_NAME3}")
echo "$0: UPSTREAM_REMOTE1='${UPSTREAM_REMOTE1}',UPSTREAM_REMOTE2='${UPSTREAM_REMOTE2}',UPSTREAM_REMOTE3='${UPSTREAM_REMOTE3}'"
if [ -n "${UPSTREAM_REMOTE1}" ]
git remote add "${WANTED_NAME3}" "${GIT_URL3}" --track "${GIT_BRANCH}" || exit 255
fi
fi
+
+ # Is not an application by default
+ IS_APP=""
+
+ # Now "walk" through all base application names
+ for APP_NAME in ${BASE_APPLICATION_NAMES}; do
+ echo "$0: project='${project}',APP_NAME='${APP_NAME}'"
+
+ # Is it part of the project's name?
+ PART=$(echo "${project}" | grep "${APP_NAME}")
+
+ # Check it
+ if [ -z "${PART}" ]
+ then
+ # Skip this entire loop
+ continue
+ fi
+
+ # Found one that maybe needs fixing
+ IS_APP="${APP_NAME}"
+
+ # Skip further search
+ break
+ done
+
+ echo "$0: IS_APP='${IS_APP}'"
+
+ # Is the current project an application (or part of it)?
+ if [ -z "${IS_APP}" ]
+ then
+ # No, then skip it
+ echo "$0: Project '${project}' is no application."
+ continue
+ fi
+
+ # Generate all sub-project names
+ EAR_APP_NAME="${IS_APP}"
+ CORE_APP_NAME="${IS_APP}-core"
+ EJB_APP_NAME="${IS_APP}-ejb"
+ LIB_APP_NAME="${IS_APP}-lib"
+ MAILER_EJB_APP_NAME="${IS_APP}-mailer-ejb"
+ MAILER_LIB_APP_NAME="${IS_APP}-mailer-lib"
+ SWING_APP_NAME="${IS_APP}-swing"
+ WAR_APP_NAME="${IS_APP}-war"
+
+ # It is an application, then run through all projects again
+ for APP_NAME in ${BASE_APPLICATION_NAMES}; do
+ echo "$0: project='${project}',APP_NAME='${APP_NAME}'"
+
+ # What project do we have?
+ if [ "${project}" = "${EAR_APP_NAME}" ]
+ then
+ # EAR (triangle symbol) project
+ PROJECT_APP_NAME="${APP_NAME}"
+ OWN_APP_NAME="${EAR_APP_NAME}"
+ elif [ "${project}" = "${CORE_APP_NAME}" ]
+ then
+ # Model library project
+ PROJECT_APP_NAME="${APP_NAME}-core"
+ OWN_APP_NAME="${CORE_APP_NAME}"
+ elif [ "${project}" = "${EJB_APP_NAME}" ]
+ then
+ # General EJB (bean symbol) project
+ PROJECT_APP_NAME="${APP_NAME}-ejb"
+ OWN_APP_NAME="${EJB_APP_NAME}"
+ elif [ "${project}" = "${LIB_APP_NAME}" ]
+ then
+ # General remote-interface project
+ PROJECT_APP_NAME="${APP_NAME}-lib"
+ OWN_APP_NAME="${LIB_APP_NAME}"
+ elif [ "${project}" = "${MAILER_EJB_APP_NAME}" ]
+ then
+ # Mailer EJB (bean symbol) project
+ PROJECT_APP_NAME="${APP_NAME}-mailer-ejb"
+ OWN_APP_NAME="${MAILER_EJB_APP_NAME}"
+ elif [ "${project}" = "${MAILER_LIB_APP_NAME}" ]
+ then
+ # Mailer remote-interface project
+ PROJECT_APP_NAME="${APP_NAME}-mailer-lib"
+ OWN_APP_NAME="${MAILER_LIB_APP_NAME}"
+ elif [ "${project}" = "${SWING_APP_NAME}" ]
+ then
+ # Swing project
+ PROJECT_APP_NAME="${APP_NAME}-swing"
+ OWN_APP_NAME="${SWING_APP_NAME}"
+ elif [ "${project}" = "${WAR_APP_NAME}" ]
+ then
+ # WAR (globe symbol) project
+ PROJECT_APP_NAME="${APP_NAME}-war"
+ OWN_APP_NAME="${WAR_APP_NAME}"
+ else
+ # Unknown, skip this
+ echo "$0: Project '${project}' is not supported. Please consider adding it."
+ break
+ fi
+
+ # Generic ...
+ LOCAL_APP_PATH="${JPROJECTS_HOME}/${PROJECT_APP_NAME}"
+
+ echo "$0: LOCAL_APP_PATH='${LOCAL_APP_PATH}',PROJECT_APP_NAME='${PROJECT_APP_NAME}'"
+ echo "$0: project='${project}',OWN_APP_NAME='${OWN_APP_NAME}'"
+
+ # Is same project name?
+ if [ "${OWN_APP_NAME}" != "${project}" ]
+ then
+ echo "$0: Not the right project: '${project}'<>'${OWN_APP_NAME}', skipping ..."
+ continue
+ elif [ "${project}" = "${LOCAL_APP_PATH##*/}" ]
+ then
+ # Skip same project
+ echo "$0: Not local-tracking same project '${project}'='${LOCAL_APP_PATH##*/}', skipping ..."
+ continue;
+ elif [ ! -d "${LOCAL_APP_PATH}" ]
+ then
+ # Other application's name does not exist
+ echo "$0: Application '${APP_NAME}' not found, skipping ..."
+ continue;
+ fi
+
+ # Local-tracking
+ LOCAL_TRACKING="${APP_NAME}-local"
+ echo "$0: LOCAL_TRACKING='${LOCAL_TRACKING}'"
+
+ # Maybe a local-tracking needs to be setup?
+ LOCAL_TRACKING_SETUP=$(git remote | grep "${LOCAL_TRACKING}")
+
+ if [ -n "${LOCAL_TRACKING_SETUP}" ]
+ then
+ echo "$0: Local-tracking from '${project}' to '${LOCAL_APP_PATH##*/}' is already setup."
+ continue
+ fi
+
+ # Setup it
+ echo "$0: Setting up local-tracking (${LOCAL_TRACKING}) from '${project}' to '${LOCAL_APP_PATH##*/}' ..."
+ git remote add "${LOCAL_TRACKING}" "${LOCAL_APP_PATH}" || exit 255
+ done
done
echo "$0: All done."