myshellconfig/bin/git-submodule-remove

23 lines
1.3 KiB
Text
Raw Normal View History

#!/bin/bash
SUBMODULE=$1
2020-10-30 00:46:59 +01:00
[[ $(git config --file=.gitmodules --get submodule.${SUBMODULE}.url >/dev/null 2>&1; echo $?) -eq 0 \
|| $(git config --file=.gitmodules --get submodule.${SUBMODULE}.path >/dev/null 2>&1; echo $?) -eq 0 \
|| $(git config --get submodule.${SUBMODULE}.url >/dev/null 2>&1; echo $?) -eq 0 \
|| $(git config --get submodule.${SUBMODULE}.path >/dev/null 2>&1; echo $?) -eq 0 ]] || exit $?
[[ $(git config --file=.gitmodules --get submodule.${SUBMODULE}.url >/dev/null 2>&1; echo $?) -eq 0 \
|| $(git config --file=.gitmodules --get submodule.${SUBMODULE}.path >/dev/null 2>&1; echo $?) -eq 0 ]] && \
loginfo "$(git config --file=.gitmodules --remove-section submodule.${SUBMODULE})"
#git commit .gitmodules -m "remove submodule $SUBMODULE from .gitconfig"
[[ $(git config --get submodule.${SUBMODULE}.url >/dev/null 2>&1; echo $?) -eq 0 \
|| $(git config --get submodule.${SUBMODULE}.path >/dev/null 2>&1; echo $?) -eq 0 ]] && \
loginfo "$(git config --remove-section submodule.${SUBMODULE})"
loginfo "$(git rm --cached "${SUBMODULE}")"
[ -d ".git/modules/${SUBMODULE}" ] && loginfo "$(rm -rf .git/modules/"${SUBMODULE}")"
loginfo "$(git commit -m "remove submodule ${SUBMODULE}" )"
[ -d "${SUBMODULE}" ] && loginfo "$(rm -rf ${SUBMODULE} )"
loginfo "submodule $SUBMODULE completely removed"