Prepend cur dir to module name

This commit is contained in:
Daniel Berteaud 2023-10-18 10:55:06 +02:00
parent 82e5ef0c83
commit adf338ea73
1 changed files with 11 additions and 8 deletions

19
ctctl
View File

@ -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