@@ -22,6 +22,7 @@ import qualified Data.Text as T
2222import Data.Text.Encoding
2323import GHC.StaticPtr
2424import Options.Applicative
25+import System.Directory
2526import System.Environment
2627import System.FilePath
2728import System.IO (hIsTerminalDevice, stdout)
@@ -263,14 +264,21 @@ ob = \case
263264 ObCommand_Init source -> initProject source
264265 ObCommand_Deploy dc -> case dc of
265266 DeployCommand_Init deployOpts -> withProjectRoot "." $ \root -> do
267+ let deployDir = _deployInitOpts_ouputDir deployOpts
268+ r <- liftIO $ canonicalizePath root
269+ rootEqualsTarget <- liftIO $ equalFilePath r <$> canonicalizePath deployDir
270+ when rootEqualsTarget $
271+ failWith $ "Deploy directory " <> T.pack deployDir <> " should not be the same as project root."
266272 thunkPtr <- readThunk root >>= \case
267− Left err -> failWith $ T.pack $ "thunk pack: " <> show err
273+ Left err -> failWith $ case err of
274+ ReadThunkError_WrongContents _ _ ->
275+ "Project root " <> T.pack r <> " is not a git repository or valid thunk"
276+ _ -> "thunk read: " <> T.pack (show err)
268277 Right (ThunkData_Packed ptr) -> return ptr
269278 Right (ThunkData_Checkout (Just ptr)) -> return ptr
270279 Right (ThunkData_Checkout Nothing) ->
271280 getThunkPtr root (_deployInitOpts_remote deployOpts)
272− let deployDir = _deployInitOpts_ouputDir deployOpts
273− sshKeyPath = _deployInitOpts_sshKey deployOpts
281+ let sshKeyPath = _deployInitOpts_sshKey deployOpts
274282 hostname = _deployInitOpts_hostname deployOpts
275283 deployInit thunkPtr (root </> "config") deployDir sshKeyPath hostname
276284 DeployCommand_Push -> deployPush "."