on master help sign in
command: Fix ob thunk pack for raw repos
67767d9Elliot Cameron
lib/command/src/Obelisk/Command/Thunk.hs+9−3
@@ -814,8 +814,8 @@ packThunk' noTrail (ThunkPackConfig force thunkConfig) thunkDir = checkThunkDire
814 Right (ThunkData_Checkout _) -> do
814 Right (ThunkData_Checkout _) -> do
815 withSpinner' ("Packing thunk " <> T.pack thunkDir)
815 withSpinner' ("Packing thunk " <> T.pack thunkDir)
816 (finalMsg noTrail $ const $ "Packed thunk " <> T.pack thunkDir) $ do
816 (finalMsg noTrail $ const $ "Packed thunk " <> T.pack thunkDir) $ do
817− thunkPtr <- modifyThunkPtrByConfig thunkConfig <$> getThunkPtr (not force) (thunkDir </> unpackedDirName) (_thunkConfig_private thunkConfig)
817+ thunkPtr <- modifyThunkPtrByConfig thunkConfig <$> getThunkPtr (not force) thunkDir (_thunkConfig_private thunkConfig)
818− callProcessAndLogOutput (Debug, Error) $ proc rmPath ["-rf", thunkDir </> unpackedDirName] -- thunkDir may be a symlink
818+ callProcessAndLogOutput (Debug, Error) $ proc rmPath ["-rf", thunkDir] -- thunkDir may be a symlink
819 createThunk thunkDir thunkPtr
819 createThunk thunkDir thunkPtr
820 pure thunkPtr
820 pure thunkPtr
821
821
@@ -828,7 +828,13 @@ modifyThunkPtrByConfig (ThunkConfig markPrivate') ptr = case markPrivate' of
828 }
828 }
829
829
830getThunkPtr :: forall m. MonadObelisk m => Bool -> FilePath -> Maybe Bool -> m ThunkPtr
830getThunkPtr :: forall m. MonadObelisk m => Bool -> FilePath -> Maybe Bool -> m ThunkPtr
831−getThunkPtr checkClean thunkDir mPrivate = do
831+getThunkPtr checkClean dir mPrivate = do
832+ let repoLocations = [(".git", "."), (unpackedDirName, unpackedDirName)]
833+ repoLocation' <- liftIO $ flip findM repoLocations $ doesDirectoryExist . (dir </>) . fst
834+ thunkDir <- case repoLocation' of
835+ Nothing -> failWith [i|Can't find an unpacked thunk in ${dir}|]
836+ Just (_, path) -> pure $ normalise $ dir </> path
837+
832 when checkClean $ ensureCleanGitRepo thunkDir True
838 when checkClean $ ensureCleanGitRepo thunkDir True
833 "thunk pack: thunk checkout contains unsaved modifications"
839 "thunk pack: thunk checkout contains unsaved modifications"
834
840