Merge pull request #2768 from unisonweb/21-12-17-get-root-branch-exists · JavaDerek/unison@0354658 · GitHub
Skip to content

Commit 0354658

Browse files
Merge pull request unisonweb#2768 from unisonweb/21-12-17-get-root-branch-exists
Add getRootBranchExists to the Codebase API
2 parents b78cb32 + 337b1a6 commit 0354658

4 files changed

Lines changed: 16 additions & 16 deletions

File tree

‎parser-typechecker/src/Unison/Codebase.hs‎

Lines changed: 1 addition & 8 deletions

‎parser-typechecker/src/Unison/Codebase/SqliteCodebase.hs‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,10 @@ sqliteCodebase debugName root action = do
518518
Codebase1.CouldntLoadRootBranch $ Cv.causalHash2to1 ch
519519
e -> error $ show e
520520

521+
getRootBranchExists :: MonadIO m => m Bool
522+
getRootBranchExists =
523+
isJust <$> runDB conn (Ops.loadMaybeRootCausalHash)
524+
521525
putRootBranch :: MonadIO m => TVar (Maybe (Q.DataVersion, Branch m)) -> Branch m -> m ()
522526
putRootBranch rootBranchCache branch1 = do
523527
-- todo: check to see if root namespace hash has been externally modified
@@ -745,6 +749,7 @@ sqliteCodebase debugName root action = do
745749
putTerm
746750
putTypeDeclaration
747751
(getRootBranch rootBranchCache)
752+
getRootBranchExists
748753
(putRootBranch rootBranchCache)
749754
(rootBranchUpdates rootBranchCache)
750755
getBranchForHash

‎parser-typechecker/src/Unison/Codebase/Type.hs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ data Codebase m v a = Codebase
6464
putTypeDeclaration :: Reference.Id -> Decl v a -> m (),
6565
-- | Get the root branch.
6666
getRootBranch :: m (Either GetRootBranchError (Branch m)),
67+
-- | Get whether the root branch exists.
68+
getRootBranchExists :: m Bool,
6769
-- | Like 'putBranch', but also adjusts the root branch pointer afterwards.
6870
putRootBranch :: Branch m -> m (),
6971
rootBranchUpdates :: m (IO (), IO (Set Branch.Hash)),

‎unison-cli/src/Unison/CommandLine/Welcome.hs‎

Lines changed: 8 additions & 8 deletions

0 commit comments

Comments
 (0)