diff options
author | Alexander Foremny <aforemny@posteo.de> | 2024-06-05 17:59:04 +0200 |
---|---|---|
committer | Alexander Foremny <aforemny@posteo.de> | 2024-06-05 17:59:04 +0200 |
commit | 5e68d300aad04406adcc974a64e7436b7b2f8cea (patch) | |
tree | 677f5d9467ffea1c76470945f0f0098297f90626 | |
parent | 9874a5f4c66d831b83930921c825f3d9db9c864e (diff) |
add `withCommit`
-rw-r--r-- | src/Store/Store.hs | 12 |
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 |