diff options
author | Fabian Kirchner <kirchner@posteo.de> | 2023-10-14 18:51:47 +0200 |
---|---|---|
committer | Fabian Kirchner <kirchner@posteo.de> | 2023-10-14 18:51:47 +0200 |
commit | c14d4628079b059cd1394598388ab4c5a4cf7650 (patch) | |
tree | a98dbd49456e2b40d8a7856e165983c1512f8959 /app | |
parent | a9c0b62b158a304f6f663832ebb7179972231502 (diff) |
also consider issues changed in current working tree
Diffstat (limited to 'app')
-rw-r--r-- | app/History.hs | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/app/History.hs b/app/History.hs index c5953b6..b6cef76 100644 --- a/app/History.hs +++ b/app/History.hs @@ -39,8 +39,8 @@ listIssues filters paths = do hashFirst : hashesRest -> do issuesInitial <- cached (append hashFirst (pack ".all")) (\_ -> getIssuesCommitAll hashFirst) commitInfos <- mapM (\hash -> cached (append hash (pack ".changed")) (\_ -> getCommitInfo hash)) hashesRest - -- TODO We also have to get the issues which changed in the working tree - let eventses = getEvents hashFirst issuesInitial commitInfos + commitInfoWorkingTree <- getCommitInfoWorkingTree paths + 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 @@ -52,15 +52,15 @@ getCommitHashes = data IssueEvent = IssueCreated - { hash :: Text, + { hash :: Maybe Text, issue :: Issue } | IssueChanged - { hash :: Text, + { hash :: Maybe Text, issue :: Issue } | IssueDeleted - { hash :: Text + { hash :: Maybe Text } deriving (Show) @@ -76,7 +76,7 @@ issueFromIssueEvent issueEvent = data CommitInfo = CommitInfo -- TODO Extact CommitInfo so we can change hash' -> hash - { hash' :: Text, + { hash' :: Maybe Text, filesChanged :: [FilePath], issues :: [Issue] } @@ -87,18 +87,28 @@ getCommitInfo hash = do (issuesCommitChanged, filesChanged) <- getIssuesAndFilesCommitChanged hash pure $ CommitInfo - { hash' = hash, + { hash' = Just hash, filesChanged = filesChanged, issues = issuesCommitChanged } +getCommitInfoWorkingTree :: [FilePath] -> IO CommitInfo +getCommitInfoWorkingTree paths = do + (issuesWorkingTreeChanged, filesChanged) <- getIssuesAndFilesWorkingTreeChanged paths + pure $ + CommitInfo + { hash' = Nothing, + filesChanged = filesChanged, + issues = issuesWorkingTreeChanged + } + getEvents :: Text -> [Issue] -> [CommitInfo] -> [[IssueEvent]] getEvents hashInitial issuesInitial commitInfos = let issueEventsesInitial = map ( \issueInitial -> [ IssueCreated - { hash = hashInitial, + { hash = Just hashInitial, issue = issueInitial } ] @@ -179,11 +189,12 @@ getIssuesWorkingTreeAll paths = do -- | Gets issues in all files which have been changed in your current -- [working -- - tree](https://git-scm.com/docs/gitglossary#Documentation/gitglossary.txt-aiddefworkingtreeaworkingtree) -getIssuesWorkingTreeChanged :: [FilePath] -> IO [Issue] -getIssuesWorkingTreeChanged paths = do +getIssuesAndFilesWorkingTreeChanged :: [FilePath] -> IO ([Issue], [FilePath]) +getIssuesAndFilesWorkingTreeChanged paths = do cwd <- getCurrentDirectory files <- gitLsFilesModifiedIn cwd paths - concat <$> catch (getIssuesPar cwd files) dieOfInvalidTreeGrepperResult + issues <- concat <$> catch (getIssuesPar cwd files) dieOfInvalidTreeGrepperResult + pure (issues, files) -- | Given the hash of a commit, get all issues in all files at the -- [tree](https://git-scm.com/docs/gitglossary#Documentation/gitglossary.txt-aiddeftreeatree) |