diff options
author | Alexander Foremny <aforemny@posteo.de> | 2024-03-25 14:23:33 +0100 |
---|---|---|
committer | Alexander Foremny <aforemny@posteo.de> | 2024-03-25 14:41:47 +0100 |
commit | 69f0021518a93db9fef11b45a464457eb9890ac5 (patch) | |
tree | d7bf38cbddd5da31ea577e5c61df8e9c88e184c4 | |
parent | 4a77e429e371bae4ab50551c7d382c6bd0af2eae (diff) |
fix: fix determine closed issues
-rw-r--r-- | app/History/IssueEvents.hs | 29 | ||||
-rw-r--r-- | app/History/Issues.hs | 21 | ||||
-rw-r--r-- | app/History/Scramble.hs | 25 |
3 files changed, 33 insertions, 42 deletions
diff --git a/app/History/IssueEvents.hs b/app/History/IssueEvents.hs index fc7bdcf..3fca32a 100644 --- a/app/History/IssueEvents.hs +++ b/app/History/IssueEvents.hs @@ -14,7 +14,7 @@ import Data.Ord (comparing) import Data.Proxy (Proxy) import GHC.Generics (Generic) import History.Plan (Id, Planable, Proto, assume, propagate, protoOf) -import History.Scramble (Scramble (..), getIssuesOfFile) +import History.Scramble (Scramble (..), getScramble) import Issue (Issue (..)) import IssueEvent (IssueEvent (..)) import IssueEvent qualified as E @@ -29,28 +29,7 @@ instance Planable IssueEvents where type Id IssueEvents = Backend.CommitHash type Proto IssueEvents = Scramble protoOf :: Proxy IssueEvents -> Backend.CommitHash -> IO Scramble - protoOf _ commitHash@Backend.WorkingTree = do - filesChanged <- Backend.getFilesOf commitHash - issues <- concat <$> mapM (getIssuesOfFile commitHash) filesChanged - pure $ - Scramble - { issues = - M.unions - [ M.singleton issue.id issue | issue <- issues - ], - .. - } - protoOf _ commitHash@(Backend.Commit _) = do - filesChanged <- Backend.getChangedFilesOf commitHash - issues <- concat <$> mapM (getIssuesOfFile commitHash) filesChanged - pure $ - Scramble - { issues = - M.unions - [ M.singleton issue.id issue | issue <- issues - ], - .. - } + protoOf _ = getScramble assume :: Scramble -> IssueEvents assume Scramble {..} = @@ -112,7 +91,7 @@ propagateIssueEvents log topIssueEvents bottomScramble = if commitHash /= topCommitHash then [ IssueCreated commitHash issue, - IssueDeleted topCommitHash issue, + IssueDeleted topCommitHash issue {closed = True}, IssueCreated bottomCommitHash bottomIssue ] else @@ -150,7 +129,7 @@ propagateIssueEvents log topIssueEvents bottomScramble = ], concat [ -- CASE 4. The issue it not present in the top/earlier history, but contained in the bottom scramble. It had to be deleted by the top/ earlier commit. - [ IssueDeleted topIssueEvents.commitHash bottomIssue, + [ IssueDeleted topIssueEvents.commitHash bottomIssue {closed = True}, IssueCreated bottomCommitHash bottomIssue ] | bottomIssue <- bottomIssues, diff --git a/app/History/Issues.hs b/app/History/Issues.hs index 63f1735..1af0084 100644 --- a/app/History/Issues.hs +++ b/app/History/Issues.hs @@ -11,7 +11,7 @@ import Data.Proxy (Proxy) import Data.Text qualified as T import GHC.Generics (Generic) import History.Plan (Id, Planable, Proto, assume, propagate, protoOf) -import History.Scramble (Scramble (..), getIssuesOfFile) +import History.Scramble (Scramble (..), getScramble) import Issue qualified as I data Issues = Issues @@ -24,17 +24,7 @@ instance Planable Issues where type Id Issues = Backend.CommitHash type Proto Issues = Scramble protoOf :: Proxy Issues -> Backend.CommitHash -> IO Scramble - protoOf _ commitHash = do - filesChanged <- Backend.getChangedFilesOf commitHash - issues <- concat <$> mapM (getIssuesOfFile commitHash) filesChanged - pure $ - Scramble - { issues = - M.unions - [ M.singleton issue.id issue | issue <- issues - ], - .. - } + protoOf _ = getScramble assume :: Scramble -> Issues assume (Scramble {..}) = Issues {..} @@ -58,13 +48,10 @@ instance Planable Issues where } } ) - ( \topIssues -> topIssues - ) + (\topIssues -> topIssues) ( \bottomIssues -> M.map - ( \bottomIssue -> - bottomIssue {I.closed = True} - ) + (\bottomIssue -> bottomIssue {I.closed = True}) bottomIssues ) topIssues.issues diff --git a/app/History/Scramble.hs b/app/History/Scramble.hs index 39a1ac7..093db98 100644 --- a/app/History/Scramble.hs +++ b/app/History/Scramble.hs @@ -1,5 +1,6 @@ module History.Scramble ( Scramble (..), + getScramble, getIssuesOfFile, fromComment, ) @@ -34,6 +35,30 @@ data Scramble = Scramble } deriving (Show, Binary, Generic) +getScramble :: Backend.CommitHash -> IO Scramble +getScramble commitHash@Backend.WorkingTree = do + filesChanged <- Backend.getFilesOf commitHash + issues <- concat <$> mapM (getIssuesOfFile commitHash) filesChanged + pure $ + Scramble + { issues = + M.unions + [ M.singleton issue.id issue | issue <- issues + ], + .. + } +getScramble commitHash@(Backend.Commit _) = do + filesChanged <- Backend.getChangedFilesOf commitHash + issues <- concat <$> mapM (getIssuesOfFile commitHash) filesChanged + pure $ + Scramble + { issues = + M.unions + [ M.singleton issue.id issue | issue <- issues + ], + .. + } + -- | Get all issues in the given directory and file. getIssuesOfFile :: Backend.CommitHash -> FilePath -> IO [I.Issue] getIssuesOfFile commitHash filename = |