From 7d77a88d714cccc1e8a0c408b7bacf58122f6ae2 Mon Sep 17 00:00:00 2001 From: Fabian Kirchner Date: Sat, 14 Oct 2023 19:01:59 +0200 Subject: filter issues by paths --- app/History.hs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'app/History.hs') diff --git a/app/History.hs b/app/History.hs index a12ea6e..21709ae 100644 --- a/app/History.hs +++ b/app/History.hs @@ -12,7 +12,7 @@ import Data.Function ((&)) import Data.List (foldl', intercalate) import Data.Maybe (catMaybes, mapMaybe) import Data.String (fromString) -import Data.Text (Text, append, lines, pack, unpack) +import Data.Text (Text, append, isPrefixOf, lines, pack, unpack) import Data.Text.Encoding (decodeUtf8) import GHC.Generics (Generic) import Issue (Issue (..), fromMatch, id) @@ -43,8 +43,16 @@ listIssues filters paths = do let eventses = getEvents hashFirst issuesInitial (commitInfos ++ [commitInfoWorkingTree]) let issues = mapMaybe issueFromIssueEvents eventses issuesFiltered = filter (applyFilter filters) issues - -- FIXME We have to only consider issues in the specified paths - pure issuesFiltered + issuesWithinPaths = + case paths of + [] -> + issuesFiltered + _ -> + filter withinPaths issuesFiltered + pure issuesWithinPaths + where + withinPaths issue = + any (\path -> isPrefixOf (pack path) (pack issue.file)) paths getCommitHashes :: IO [Text] getCommitHashes = -- cgit v1.2.3