looper/download-modules.sh

21 lines
924 B
Bash
Raw Normal View History

2024-09-28 10:31:06 -07:00
git config -f .gitmodules --get-regexp '^submodule\..*\.path$' |
while read -r KEY MODULE_PATH; do
[ -d "${MODULE_PATH}" ] && rm -rf "${MODULE_PATH}"
NAME="$(echo "${KEY}" | sed 's/^submodule\.\(.*\)\.path$/\1/')"
url_key="$(echo "${KEY}" | sed 's/\.path$/.url/')"
branch_key="$(echo "${KEY}" | sed 's/\.path$/.branch/')"
required_key="$(echo "${KEY}" | sed 's/\.path$/.required/')"
commit_key="$(echo "${KEY}" | sed 's/\.path$/.commit/')"
URL="$(git config -f .gitmodules --get "${url_key}")"
BRANCH="$(git config -f .gitmodules --default "$(git config -f .gitmodules --get "${branch_key}")" --get "${commit_key}")"
REQUIRED="$(git config -f .gitmodules --get "${required_key}")"
if [ -n "$BRANCH" ]; then
BRANCH=( "-b" "${BRANCH}" )
else
BRANCH=( )
fi
if [ ! "$REQUIRED" = "false" ]; then
git clone ${BRANCH[@]} --recursive --depth 1 -- "${URL}" "${MODULE_PATH}" || continue
fi
done