From adf338ea737bc4c72ad962b81c50be1b9237856b Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Wed, 18 Oct 2023 10:55:06 +0200 Subject: [PATCH] Prepend cur dir to module name --- ctctl | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/ctctl b/ctctl index 9445ca3..d14b096 100755 --- a/ctctl +++ b/ctctl @@ -466,16 +466,17 @@ ctctl_handle_prep_scripts(){ ctctl_add_submodule(){ local NAME=$1 - local URL=$2 - local BRANCH=$3 - local DIR=$4 + local MODULE=$2 + local URL=$3 + local BRANCH=$4 + local DIR=$5 mkdir -p ${DIR} if [ ! -d ${DIR}/${NAME} ]; then - echo "Adding ${NAME} submodule from ${URL} (branch ${BRANCH})" - git submodule add --branch ${BRANCH} --name ${NAME} --force ${URL} ${DIR}/${NAME} + echo "Adding ${MODULE} submodule from ${URL} (branch ${BRANCH})" + git submodule add --branch ${BRANCH} --name ${MODULE} --force ${URL} ${DIR}/${NAME} else - echo "Updating ${NAME} submodule from ${URL} (branch ${BRANCH})" + echo "Updating ${MODULE} submodule from ${URL} (branch ${BRANCH})" git submodule set-branch --branch ${BRANCH} ${DIR}/${NAME} fi git submodule update --init --recursive --remote --merge ${DIR}/${NAME} @@ -488,17 +489,19 @@ ctctl_update_submodules(){ local URL=$(echo ${BUNDLE} | jq -r .url) local BRANCH=$(echo ${BUNDLE} | jq -r .branch) local NAME=$(basename ${URL} .git) + local MODULE=$(basename $(pwd))_${NAME} # If the branch is not defined, default to master if [ "${BRANCH}" = "null" ]; then BRANCH=master fi - ctctl_add_submodule ${NAME} ${URL} ${BRANCH} bundles + ctctl_add_submodule ${NAME} ${MODULE} ${URL} ${BRANCH} bundles if [ -e "bundles/${NAME}/bundles.yml" ]; then for DEP in $(yq e -o=j -I=0 '.dependencies[]' bundles/${NAME}/bundles.yml); do local DEP_URL=$(echo ${DEP} | jq -r .url) local DEP_BRANCH=$(echo ${DEP} | jq -r .branch) local DEP_NAME="${NAME}_$(basename ${DEP_URL} .git)" + local DEP_MODULE="${MODULE}_$(basename ${DEP_URL} .git)" # If the branch is not defined, assume the same as the parent bundle if [ "${DEP_BRANCH}" = "null" ]; then @@ -509,7 +512,7 @@ ctctl_update_submodules(){ if echo ${DEP_URL} | grep -qE '^\.\./'; then DEP_URL=$(dirname ${URL})/$(echo ${DEP_URL} | sed -E 's|^\.\./||') fi - ctctl_add_submodule ${DEP_NAME} ${DEP_URL} ${DEP_BRANCH} bundles + ctctl_add_submodule ${DEP_NAME} ${DEP_MODULE} ${DEP_URL} ${DEP_BRANCH} bundles done fi done