21 lines
924 B
Bash
21 lines
924 B
Bash
|
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
|