Skip to content

Commit

Permalink
add --force option to continue on error
Browse files Browse the repository at this point in the history
  • Loading branch information
go2null committed Oct 20, 2019
1 parent 7215888 commit f872741
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions bin/git-delete-submodule
Expand Up @@ -2,9 +2,13 @@

abort() {
error="$1" && shift
echo "FATAL: $*" 1>&2 && exit "$error"
echo "ERROR: $*" 1>&2
test -z "$FORCE" && exit "$error"
}

# Don't abort on failures. This allows to cleanup after a rpevious failure.
[ "$1" = '--force' ] && FORCE=1 && shift

test -z "$1" && abort 1 'Submodule required'
cd "$(git root)" || abort 5 'Cannot change to repository root'
test ! -f '.gitmodules' && abort 2 '.gitmodules file not found'
Expand All @@ -30,7 +34,6 @@ git add '.gitmodules'
[ "$(wc -l '.gitmodules' | cut -d' ' -f1)" = '0' ] && git rm -f '.gitmodules'

# 3. Need to confirm and commit the changes for yourself
echo
if git submodule status >/dev/null 2>&1 \
&& ! git submodule status | grep "$NAME"; then
echo "Successfully deleted $NAME."
Expand All @@ -39,6 +42,5 @@ else
fi
echo
git submodule status
echo
echo 'Confirm the output of `git submodule status` above' \
' and commit the changes for yourself.'

0 comments on commit f872741

Please sign in to comment.