diff options
author | Alexander Foremny <aforemny@posteo.de> | 2024-03-21 05:35:00 +0100 |
---|---|---|
committer | Alexander Foremny <aforemny@posteo.de> | 2024-03-25 07:45:59 +0100 |
commit | f83b424bf70b7b14b0268aeeafe1b3483fced49f (patch) | |
tree | 348a60e815f4bee492f58dea903ebc380029d61f /app/History | |
parent | fc0afaaa273f5b5d3696df87d70d5347a13bb9ac (diff) |
chore: Git -> Backend
Diffstat (limited to 'app/History')
-rw-r--r-- | app/History/IssueEvents.hs | 20 | ||||
-rw-r--r-- | app/History/Issues.hs | 10 | ||||
-rw-r--r-- | app/History/Scramble.hs | 10 |
3 files changed, 20 insertions, 20 deletions
diff --git a/app/History/IssueEvents.hs b/app/History/IssueEvents.hs index 176d660..fc7bdcf 100644 --- a/app/History/IssueEvents.hs +++ b/app/History/IssueEvents.hs @@ -3,6 +3,7 @@ module History.IssueEvents ) where +import Backend qualified import Data.Binary (Binary) import Data.Function (on) import Data.List @@ -12,7 +13,6 @@ import Data.Maybe (fromMaybe) import Data.Ord (comparing) import Data.Proxy (Proxy) import GHC.Generics (Generic) -import Git qualified import History.Plan (Id, Planable, Proto, assume, propagate, protoOf) import History.Scramble (Scramble (..), getIssuesOfFile) import Issue (Issue (..)) @@ -20,17 +20,17 @@ import IssueEvent (IssueEvent (..)) import IssueEvent qualified as E data IssueEvents = IssueEvents - { commitHash :: Git.CommitHash, + { commitHash :: Backend.CommitHash, issueEvents :: [E.IssueEvent] } deriving (Show, Generic, Binary) instance Planable IssueEvents where - type Id IssueEvents = Git.CommitHash + type Id IssueEvents = Backend.CommitHash type Proto IssueEvents = Scramble - protoOf :: Proxy IssueEvents -> Git.CommitHash -> IO Scramble - protoOf _ commitHash@Git.WorkingTree = do - filesChanged <- Git.getFilesOf commitHash + protoOf :: Proxy IssueEvents -> Backend.CommitHash -> IO Scramble + protoOf _ commitHash@Backend.WorkingTree = do + filesChanged <- Backend.getFilesOf commitHash issues <- concat <$> mapM (getIssuesOfFile commitHash) filesChanged pure $ Scramble @@ -40,8 +40,8 @@ instance Planable IssueEvents where ], .. } - protoOf _ commitHash@(Git.Commit _) = do - filesChanged <- Git.getChangedFilesOf commitHash + protoOf _ commitHash@(Backend.Commit _) = do + filesChanged <- Backend.getChangedFilesOf commitHash issues <- concat <$> mapM (getIssuesOfFile commitHash) filesChanged pure $ Scramble @@ -63,7 +63,7 @@ instance Planable IssueEvents where } propagate :: - [Git.CommitHash] -> + [Backend.CommitHash] -> IssueEvents -> Scramble -> IssueEvents @@ -96,7 +96,7 @@ instance Planable IssueEvents where -- So, in the case `issue-1` has been re-opened, we cannot track its deletion at `commit-b`, because whether it was re-opened or originally created at `commit-b` depends on whether `issue-1` is present in the bottom `commit-a`, that we process only later. Thus, the scramble of commit `commit-b` cannot safely advance the issue's original commit, and we use this information to track re-opening of commits at later commits. -- -- Note that in the whole process, issue change events and issue deletion events can never be bottom-most/latest events, as they would depend on information not yet known, ie. the first commit can neither change nor delete an issue. -propagateIssueEvents :: [Git.CommitHash] -> IssueEvents -> Scramble -> IssueEvents +propagateIssueEvents :: [Backend.CommitHash] -> IssueEvents -> Scramble -> IssueEvents propagateIssueEvents log topIssueEvents bottomScramble = IssueEvents { commitHash = bottomScramble.commitHash, diff --git a/app/History/Issues.hs b/app/History/Issues.hs index 08ad772..63f1735 100644 --- a/app/History/Issues.hs +++ b/app/History/Issues.hs @@ -3,29 +3,29 @@ module History.Issues ) where +import Backend qualified import Data.Binary (Binary) import Data.Function (on) import Data.Map qualified as M import Data.Proxy (Proxy) import Data.Text qualified as T import GHC.Generics (Generic) -import Git qualified import History.Plan (Id, Planable, Proto, assume, propagate, protoOf) import History.Scramble (Scramble (..), getIssuesOfFile) import Issue qualified as I data Issues = Issues - { commitHash :: Git.CommitHash, + { commitHash :: Backend.CommitHash, issues :: M.Map T.Text I.Issue } deriving (Show, Generic, Binary) instance Planable Issues where - type Id Issues = Git.CommitHash + type Id Issues = Backend.CommitHash type Proto Issues = Scramble - protoOf :: Proxy Issues -> Git.CommitHash -> IO Scramble + protoOf :: Proxy Issues -> Backend.CommitHash -> IO Scramble protoOf _ commitHash = do - filesChanged <- Git.getChangedFilesOf commitHash + filesChanged <- Backend.getChangedFilesOf commitHash issues <- concat <$> mapM (getIssuesOfFile commitHash) filesChanged pure $ Scramble diff --git a/app/History/Scramble.hs b/app/History/Scramble.hs index 9004dbf..39a1ac7 100644 --- a/app/History/Scramble.hs +++ b/app/History/Scramble.hs @@ -5,6 +5,7 @@ module History.Scramble ) where +import Backend qualified import CMark qualified as D import Comment qualified as G import Control.Exception (Handler (..), catches) @@ -17,7 +18,6 @@ import Data.Text.Lazy qualified as LT import Data.Text.Lazy.Encoding qualified as LT import Exception qualified as E import GHC.Generics (Generic) -import Git qualified import Issue qualified as I import Issue.Parser qualified as I import Issue.Tag qualified as I @@ -28,14 +28,14 @@ import Render qualified as P -- | `Scramble` records the complete issues ONLY in files that have -- been changed in the commit. data Scramble = Scramble - { commitHash :: Git.CommitHash, + { commitHash :: Backend.CommitHash, filesChanged :: [FilePath], issues :: M.Map T.Text I.Issue } deriving (Show, Binary, Generic) -- | Get all issues in the given directory and file. -getIssuesOfFile :: Git.CommitHash -> FilePath -> IO [I.Issue] +getIssuesOfFile :: Backend.CommitHash -> FilePath -> IO [I.Issue] getIssuesOfFile commitHash filename = ( fmap catMaybes . parMapM (fromComment commitHash) =<< G.getComments commitHash filename @@ -45,9 +45,9 @@ getIssuesOfFile commitHash filename = ] -- | Note that `provenance` is trivial and needs to be fixed up later. -fromComment :: Git.CommitHash -> G.Comment -> IO (Maybe I.Issue) +fromComment :: Backend.CommitHash -> G.Comment -> IO (Maybe I.Issue) fromComment commitHash comment = do - commit <- Git.getCommitOf commitHash + commit <- Backend.getCommitOf commitHash let provenance = I.Provenance commit commit pure $ |