From e35a5223fb72ee334cbae06ac2cd0024579621ab Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Wed, 12 Jul 2017 23:12:12 +0200 Subject: [PATCH] Continued: - separated user-llogin stuff from juser-core/lib to juser-login-core/lib - locale tracking of working copies can be neat if you (only pull from them!) cherry-pick a lot, see my cherry-jprojects.sh script why ... :-) MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .jprojects.sh | 14 ++-- fix-project-remotes.sh | 172 +++++++++++++++++++++++++++++++++++++---- 2 files changed, 165 insertions(+), 21 deletions(-) diff --git a/.jprojects.sh b/.jprojects.sh index 08fe8e7..8638310 100644 --- a/.jprojects.sh +++ b/.jprojects.sh @@ -11,6 +11,7 @@ LIBRARIES="jcore jcoreee \ jcontacts-core jcontacts-lib \ jcontacts-business-core jcontacts-business-lib \ juser-core juser-lib \ + juser-login-core juser-login-lib \ juser-activity-core juser-activity-lib \ jletter-core jletter-lib \ jaddressbook-core jaddressbook-lib \ @@ -22,14 +23,17 @@ LIBRARIES="jcore jcoreee \ jshop-core jshop-ee-lib \ jshop-receipt-lib" +# Base application names (all) +BASE_APPLICATION_NAMES="addressbook jfinancials jjobs jrecruiter pizzaservice" + # Applications and their special libs/EJBs -APPLICATIONS="pizzaservice-core pizzaservice-lib pizzaservice-mailer pizzaservice-ejb pizzaservice-swing \ - jjobs-core jjobs-lib jjobs-mailer jjobs-ejb jjobs-war jjobs \ - jfinancials-core jfinancials-lib jfinancials-mailer jfinancials-ejb jfinancials-war jfinancials - addressbook-core addressbook-lib addressbook-mailer addressbook-ejb addressbook-war addressbook addressbook-uml" +APPLICATIONS="pizzaservice-core pizzaservice-lib pizzaservice-mailer-ejb pizzaservice-mailer-lib pizzaservice-ejb pizzaservice-swing \ + jjobs-core jjobs-lib jjobs-mailer-ejb jjobs-mailer-lib jjobs-ejb jjobs-war jjobs \ + jfinancials-core jfinancials-lib jfinancials-mailer-ejb jfinancials-mailer-lib jfinancials-ejb jfinancials-war jfinancials + addressbook-core addressbook-lib addressbook-mailer-ejb addressbook-mailer-lib addressbook-ejb addressbook-war addressbook addressbook-uml" # Company-specific projects -COMPANY_APPS="jrecruiter-core jrecruiter-lib jrecruiter-mailer jrecruiter-ejb jrecruiter-war jrecruiter" +COMPANY_APPS="jrecruiter-core jrecruiter-lib jrecruiter-mailer-ejb jrecruiter-mailer-lib jrecruiter-ejb jrecruiter-war jrecruiter" # Broken (needs fixing) BROKEN="addressbook-swing jfinancials-swing pizzaservice-war pizzaservice" diff --git a/fix-project-remotes.sh b/fix-project-remotes.sh index acecde2..0ceb6d5 100755 --- a/fix-project-remotes.sh +++ b/fix-project-remotes.sh @@ -30,6 +30,7 @@ for project in ${LIST}; do 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" @@ -37,9 +38,12 @@ for project in ${LIST}; do 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 @@ -48,7 +52,7 @@ for project in ${LIST}; do continue fi - REMOTES=`git remote | wc -l` + REMOTES=$(git remote | wc -l) echo "$0: REMOTES='${REMOTES}'" if [ "${REMOTES}" = "0" ] @@ -68,11 +72,11 @@ for project in ${LIST}; do 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}" ] @@ -87,10 +91,10 @@ for project in ${LIST}; do 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}" ] @@ -143,14 +147,14 @@ for project in ${LIST}; do 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}" ] @@ -163,9 +167,9 @@ for project in ${LIST}; do 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}" ] @@ -199,6 +203,142 @@ for project in ${LIST}; do 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." -- 2.39.5