diff options
-rw-r--r-- | app/History.hs | 7 | ||||
-rw-r--r-- | app/Main.hs | 15 |
2 files changed, 14 insertions, 8 deletions
diff --git a/app/History.hs b/app/History.hs index 48dbbc7..9501b1b 100644 --- a/app/History.hs +++ b/app/History.hs @@ -26,7 +26,10 @@ import Prelude hiding (id, lines) -- @topic caching -- @backlog -getHistory :: IO ([Issue], [(CommitHash, [IssueEvent])]) +getHistory :: IO [(CommitHash, [IssueEvent], [Issue])] getHistory = do commitInfos <- fromPartialCommitInfos <$> getPartialCommitInfos - pure ((last commitInfos).issues, issueEvents commitInfos) + let commitHashes = map (.hash) commitInfos + issueEventses = map snd $ issueEvents commitInfos + issueses = map (.issues) commitInfos + pure (zip3 commitHashes issueEventses issueses) diff --git a/app/Main.hs b/app/Main.hs index 163af8e..d6f653c 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -547,7 +547,7 @@ idArg = O.strArgument ( O.metavar "ID" <> O.completer - (O.listIOCompleter $ catMaybes . map I.id . fst <$> getHistory) + (O.listIOCompleter $ catMaybes . map I.id . trd3 . last <$> getHistory) ) editFlag :: O.Parser Bool @@ -568,7 +568,7 @@ main = do O.execParser (O.info (options <**> O.helper) O.idm) >>= \case Options {internalTags, colorize, noPager, width, command = List {sort, filters, files, group = Just group}} -> do let withinPath issue = if null files then True else any (\file -> file `isPrefixOf` issue.file) files - ungroupedIssues <- applySorts sort . applyFilters filters . filter withinPath . fst <$> getHistory + ungroupedIssues <- applySorts sort . applyFilters filters . filter withinPath . trd3 . last <$> getHistory let groupedIssues = I.groupIssuesBy group ungroupedIssues putDoc colorize noPager width . P.vsep @@ -608,7 +608,7 @@ main = do (M.toList groupedIssues) Options {internalTags, colorize, noPager, width, command = List {sort, filters, files, group = Nothing}} -> do let withinPath issue = if null files then True else any (\file -> file `isPrefixOf` issue.file) files - issues <- applySorts sort . applyFilters filters . filter withinPath . fst <$> getHistory + issues <- applySorts sort . applyFilters filters . filter withinPath . trd3 . last <$> getHistory putDoc colorize noPager width . P.vsep $ map ( \issue -> @@ -629,7 +629,7 @@ main = do ) issues Options {colorize, noPager, width, command = Log} -> do - (_, ess') <- getHistory + ess' <- map (\(commitHash, issueEvents, _) -> (commitHash, issueEvents)) <$> getHistory putDoc colorize noPager width . P.vsep $ concatMap ( \(hash, es') -> @@ -647,7 +647,7 @@ main = do ) (reverse ess') Options {colorize, width, command = Show {id, edit}} -> do - issues <- fst <$> getHistory + issues <- trd3 . last <$> getHistory issue <- case find ((==) (Just id) . I.id) issues of Nothing -> die (printf "no issue with id `%s'\n" id) @@ -701,7 +701,7 @@ main = do ++ show issue.start.row ++ "\n" Options {colorize, noPager, width, internalTags, command = Tags} -> do - issues <- fst <$> getHistory + issues <- trd3 . last <$> getHistory let tags = concatMap ( \issue -> @@ -787,3 +787,6 @@ putDoc colorize noPager width doc = do else LT.putStr s foreign import ccall "unistd.h isatty" c_isatty :: Int -> IO Int + +trd3 :: (a, b, c) -> c +trd3 (_, _, c) = c |