on master help sign in
Support building git directories that have replaced thunks but are not thunks themselves
commit48bf77a33c3e4747a678a967f7a263a75f0f2850 authorRyan Trinkle <ryan.trinkle@gmail.com> dateWed 17 Jan 2018, 16:12 (9 years ago) parent511be22
1 file changed+7−3
command/src/Obelisk/Command/Thunk.hs+7−3
command/src/Obelisk/Command/Thunk.hs+7−3
@@ -67,7 +67,7 @@ import Development.Placeholders
6767data ThunkData
6868 = ThunkData_Packed ThunkPtr
6969 -- ^ Packed thunk
70− | ThunkData_Checkout ThunkPtr
70+ | ThunkData_Checkout (Maybe ThunkPtr)
7171 -- ^ Checked out thunk that was unpacked from this pointer
7272 deriving (Show, Eq, Ord)
7373
@@ -169,7 +169,11 @@ readThunk :: FilePath -> IO (Either ReadThunkError ThunkData)
169169readThunk thunkDir = do
170170 files <- listDirectory thunkDir
171171 case ".git" `elem` files of
172− True -> fmap ThunkData_Checkout <$> readPackedThunk (thunkDir </> ".git" </> "obelisk" </> "orig-thunk")
172+ True -> fmap ThunkData_Checkout <$> do
173+ let origThunkPath = thunkDir </> ".git" </> "obelisk" </> "orig-thunk"
174+ doesDirectoryExist origThunkPath >>= \case
175+ True -> fmap Just <$> readPackedThunk origThunkPath
176+ False -> return $ return Nothing
173177 False -> fmap ThunkData_Packed <$> readPackedThunk thunkDir
174178
175179-- | Read a thunk and validate that it is exactly a packed thunk.
@@ -318,7 +322,7 @@ updateThunkToLatest target = do
318322 Left err -> fail $ "thunk update: " <> show err
319323 Right c -> return $ case c of
320324 ThunkData_Packed t -> (target, t)
321− ThunkData_Checkout t -> (target </> ".git" </> "obelisk", t)
325+ ThunkData_Checkout _ -> fail "cannot update an unpacked thunk"
322326 let src = _thunkPtr_source ptr
323327 rev <- getLatestRev src
324328 overwriteThunk overwrite $ ThunkPtr