Skip to content

Commit

Permalink
Fix behaviour of branch command
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisPenner committed Jul 2, 2024
1 parent 5c675df commit 6ae9f8b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion codebase2/codebase-sqlite/U/Codebase/Sqlite/Queries.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3918,7 +3918,7 @@ setProjectBranchHead description projectId branchId causalHashId = do
reason = description
}

expectProjectBranchHead :: ProjectId -> ProjectBranchId -> Transaction CausalHashId
expectProjectBranchHead :: (HasCallStack) => ProjectId -> ProjectBranchId -> Transaction CausalHashId
expectProjectBranchHead projectId branchId =
queryOneCol
[sql|
Expand Down
9 changes: 5 additions & 4 deletions unison-cli/src/Unison/Codebase/Editor/HandleInput/Branch.hs
Original file line number Diff line number Diff line change
Expand Up @@ -105,17 +105,18 @@ createBranch description createFrom project getNewBranchName = do
Cli.Env {codebase} <- ask
(mayParentBranchId, newBranchCausalHashId) <- case createFrom of
CreateFrom'ParentBranch parentBranch -> Cli.runTransaction do
Q.expectProjectBranchHead projectId (parentBranch ^. #branchId)
newBranchCausalHashId <- Q.expectProjectBranchHead projectId (parentBranch ^. #branchId)
pure (Just (parentBranch ^. #branchId), newBranchCausalHashId)
newBranchCausalHashId <- Q.expectProjectBranchHead parentBranch.projectId parentBranch.branchId
let parentBranchId = if parentBranch.projectId == projectId then Just parentBranch.branchId else Nothing
pure (parentBranchId, newBranchCausalHashId)
CreateFrom'Nothingness -> Cli.runTransaction do
(_, causalHashId) <- Codebase.emptyCausalHash
pure (Nothing, causalHashId)
CreateFrom'NamespaceWithParent parentBranch namespace -> do
liftIO $ Codebase.putBranch codebase namespace
Cli.runTransaction $ do
newBranchCausalHashId <- Q.expectCausalHashIdByCausalHash (Branch.headHash namespace)
pure (Just (parentBranch ^. #branchId), newBranchCausalHashId)
let parentBranchId = if parentBranch.projectId == projectId then Just parentBranch.branchId else Nothing
pure (parentBranchId, newBranchCausalHashId)
CreateFrom'Namespace branch -> do
liftIO $ Codebase.putBranch codebase branch
Cli.runTransaction $ do
Expand Down

0 comments on commit 6ae9f8b

Please sign in to comment.