2020-10-29 09:25:15 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
SUBMODULE=$1
|
2020-10-30 00:59:56 +01:00
|
|
|
logdebug "Check if entry for submodule exist in .git/config and .gitmodules"
|
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 $?
|
2020-10-30 00:59:56 +01:00
|
|
|
#
|
|
|
|
logdebug "Remove entry for submodule from .gitmodules, if exist"
|
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 ]] && \
|
|
|
|
loginfo "$(git config --file=.gitmodules --remove-section submodule.${SUBMODULE})"
|
|
|
|
|
2020-10-30 00:59:56 +01:00
|
|
|
loginfo "$(git commit .gitmodules -m 'remove submodule-entry for '"$SUBMODULE"' from .gitconfig')"
|
2020-10-30 11:59:06 +01:00
|
|
|
logdebug "Remove entry for submodule from .git/config, if exist"
|
2020-10-30 00:46:59 +01:00
|
|
|
[[ $(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})"
|
|
|
|
|
2020-10-30 00:59:56 +01:00
|
|
|
logdebug "Remove submodule from stage"
|
2020-10-30 00:46:59 +01:00
|
|
|
loginfo "$(git rm --cached "${SUBMODULE}")"
|
2020-10-30 00:59:56 +01:00
|
|
|
|
|
|
|
logdebug "Remove submodule from unstaged .git/modules/*"
|
2020-10-30 00:46:59 +01:00
|
|
|
[ -d ".git/modules/${SUBMODULE}" ] && loginfo "$(rm -rf .git/modules/"${SUBMODULE}")"
|
2020-10-30 00:59:56 +01:00
|
|
|
|
2020-10-30 00:46:59 +01:00
|
|
|
loginfo "$(git commit -m "remove submodule ${SUBMODULE}" )"
|
2020-10-30 00:59:56 +01:00
|
|
|
|
|
|
|
logdebug "remove submodule from repo"
|
2020-10-30 00:46:59 +01:00
|
|
|
[ -d "${SUBMODULE}" ] && loginfo "$(rm -rf ${SUBMODULE} )"
|
2020-10-29 09:25:15 +01:00
|
|
|
loginfo "submodule $SUBMODULE completely removed"
|
|
|
|
|