
module SafeRemoval (
  safeToRemove
  ) where

import Control.Monad

import Git
import SubMods
import Tools
    
safeToRemove::IO Bool
safeToRemove = do
  submodules <- getRecursiveSubmods
  submodsSafe <- forM submodules $ \submod ->
                 inDir (modDir submod) safeToRemove
  modHasChanged <- hasChanged
  modNeedsPush <- needsPush
  let isSafeToRemove = not (modHasChanged || modNeedsPush)
  return $ isSafeToRemove && and submodsSafe
