Skip to content

Commit

Permalink
fix: handle package removal failures
Browse files Browse the repository at this point in the history
  • Loading branch information
kriansa committed Feb 13, 2021
1 parent 15f7633 commit f871a64
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
6 changes: 5 additions & 1 deletion lib/cmds/remove.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,11 @@ function remove_pkg_repo {

# Remove package from git, then from DB, them commit the change
if db::package_exists "$pkg"; then
git::remove_submodule "$pkg"
if ! git::remove_submodule "$pkg"; then
error "Failed to remove $pkg locally. Please check the logs!"
return 1
fi

db::remove_package "$pkg"
git::commit ":fire: remove $pkg"
removed=1
Expand Down
7 changes: 4 additions & 3 deletions lib/git.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,12 @@ function git::remove_submodule {

# Remove the git submodule completely
git submodule deinit -f "$pkg_name"
git rm -rf "$pkg_name"
rm -rf ".git/modules/$pkg_name"

# Remove the package locally
rm -rf "$pkg_name"
# Remove from local & from git -- although not strictly necessary, return statement is here to
# make explicit that we rely upon the return code of this call to decide whether this entire
# command succeded or failed
git rm -rf "$pkg_name" || return 1
) > /dev/null
}

Expand Down

0 comments on commit f871a64

Please sign in to comment.