aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/Store/Store.hs12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/Store/Store.hs b/src/Store/Store.hs
index 511d822..b58a2da 100644
--- a/src/Store/Store.hs
+++ b/src/Store/Store.hs
@@ -1,6 +1,7 @@
module Store.Store
( StoreM,
withStore,
+ withCommit,
listFiles,
readFile,
writeFile,
@@ -72,11 +73,22 @@ withStore repoPath ref action = do
Just cid <- fmap Tagged <$> G.resolveReference ref
tid <- (.commitTree) <$> G.lookupCommit cid
pure (cid, tid)
+
runReaderT
(evalStateT (runStoreT action) (State {cid, tid}))
(Env {repo, ref})
`finally` G.runRepository GB.lgFactory repo G.closeRepository
+withCommit :: G.CommitOid GB.LgRepo -> StoreM a -> StoreM a
+withCommit cid action = do
+ Env {repo, ref} <- ask
+ liftIO do
+ tid <- G.runRepository GB.lgFactory repo do
+ (.commitTree) <$> G.lookupCommit cid
+ runReaderT
+ (evalStateT (runStoreT action) (State {cid, tid}))
+ (Env {repo, ref})
+
listDirectory :: FilePath -> StoreM [FilePath]
listDirectory dir' = do
State {tid} <- get