@@ -24,6 +24,7 @@ module Obelisk.Command.Thunk
2424 , packThunk
2525 , readThunk
2626 , getThunkPtr
27+ , getThunkPtr'
2728 ) where
2829
2930import Control.Applicative
@@ -546,8 +547,11 @@ packThunk thunkDir upstream = readThunk thunkDir >>= \case
546547 liftIO $ createThunk thunkDir thunkPtr
547548
548549getThunkPtr :: MonadObelisk m => FilePath -> String -> m ThunkPtr
549−getThunkPtr thunkDir upstream = do
550− liftIO (checkGitCleanStatus thunkDir) >>= \case
550+getThunkPtr = getThunkPtr' True
551+
552+getThunkPtr' :: MonadObelisk m => Bool -> FilePath -> String -> m ThunkPtr
553+getThunkPtr' checkClean thunkDir upstream = do
554+ when checkClean $ liftIO (checkGitCleanStatus thunkDir) >>= \case
551555 False -> do
552556 statusDebug <- liftIO $ fmap (T.strip . T.pack) $ readProcess "hub"
553557 [ "-C", thunkDir, "status", "--ignored" ] ""
@@ -558,7 +562,7 @@ getThunkPtr thunkDir upstream = do
558562
559563 -- Check whether there are any stashes
560564 stashOutput <- liftIO $ fmap T.pack $ readProcess "hub" [ "-C", thunkDir, "stash", "list" ] ""
561− case T.null stashOutput of
565+ when checkClean $ case T.null stashOutput of
562566 False -> do
563567 failWith $ T.unlines $
564568 [ "thunk pack: thunk checkout has stashes"
@@ -577,7 +581,7 @@ getThunkPtr thunkDir upstream = do
577581 Nothing -> failWith $ T.pack $ "thunk pack: upstream " <> upstream <> " does not exist. Available upstreams are " <> L.intercalate ", " remotes
578582 Just _ -> return ()
579583 -- iterate over cartesian product
580− forM_ repoHeads $ \hd -> do
584+ when checkClean $ forM_ repoHeads $ \hd -> do
581585 [localRev] <- liftIO $ lines <$> readProcess "hub" [ "-C", thunkDir, "rev-parse", hd ] ""
582586 forM_ remotes $ \rm -> do
583587 --TODO: The error you get if a branch isn't pushed anywhere could be made more user friendly