-
Notifications
You must be signed in to change notification settings - Fork 272
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5041 from unisonweb/cp/project-root
Project Roots
- Loading branch information
Showing
165 changed files
with
4,435 additions
and
4,693 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
codebase2/codebase-sqlite/U/Codebase/Sqlite/ProjectReflog.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
{-# LANGUAGE RecordWildCards #-} | ||
{-# LANGUAGE ViewPatterns #-} | ||
|
||
module U.Codebase.Sqlite.ProjectReflog | ||
( Entry (..), | ||
project_, | ||
branch_, | ||
projectAndBranch_, | ||
) | ||
where | ||
|
||
import Control.Lens | ||
import Data.Text (Text) | ||
import Data.Time (UTCTime) | ||
import U.Codebase.Sqlite.DbId (CausalHashId, ProjectBranchId, ProjectId) | ||
import Unison.Sqlite (FromRow (..), ToRow (..), field) | ||
|
||
data Entry project branch causal = Entry | ||
{ project :: project, | ||
branch :: branch, | ||
time :: UTCTime, | ||
fromRootCausalHash :: Maybe causal, | ||
toRootCausalHash :: causal, | ||
reason :: Text | ||
} | ||
deriving stock (Eq, Show, Functor, Foldable, Traversable) | ||
|
||
project_ :: Lens (Entry project branch causal) (Entry project' branch causal) project project' | ||
project_ = lens project (\e p -> e {project = p}) | ||
|
||
branch_ :: Lens (Entry project branch causal) (Entry project branch' causal) branch branch' | ||
branch_ = lens branch (\e b -> e {branch = b}) | ||
|
||
-- | Both Project and Branch Ids are required to load a branch, so this is often more useful. | ||
projectAndBranch_ :: Lens (Entry project branch causal) (Entry project' branch' causal) (project, branch) (project', branch') | ||
projectAndBranch_ = lens (\Entry {..} -> (project, branch)) (\e (project, branch) -> e {project = project, branch = branch}) | ||
|
||
instance ToRow (Entry ProjectId ProjectBranchId CausalHashId) where | ||
toRow (Entry proj branch time fromRootCausalHash toRootCausalHash reason) = | ||
toRow (proj, branch, time, fromRootCausalHash, toRootCausalHash, reason) | ||
|
||
instance FromRow (Entry ProjectId ProjectBranchId CausalHashId) where | ||
fromRow = do | ||
project <- field | ||
branch <- field | ||
time <- field | ||
fromRootCausalHash <- field | ||
toRootCausalHash <- field | ||
reason <- field | ||
pure $ Entry {..} |
Oops, something went wrong.