diff options
Diffstat (limited to 'app/History')
-rw-r--r-- | app/History/CommitHash.hs | 14 | ||||
-rw-r--r-- | app/History/CommitInfo.hs | 4 | ||||
-rw-r--r-- | app/History/IssueEvent.hs | 28 |
3 files changed, 44 insertions, 2 deletions
diff --git a/app/History/CommitHash.hs b/app/History/CommitHash.hs index f1b8283..cbe4db1 100644 --- a/app/History/CommitHash.hs +++ b/app/History/CommitHash.hs @@ -8,6 +8,7 @@ where import Data.Binary (Binary) import Data.Text qualified as T import GHC.Generics (Generic) +import Render qualified as P data CommitHash = WorkingTree @@ -21,3 +22,16 @@ toShortText (Commit hash) = T.take 7 hash toText :: CommitHash -> T.Text toText WorkingTree = "<dirty>" toText (Commit hash) = hash + +instance P.Render CommitHash where + render = P.render . P.Detailed + +instance P.Render (P.Detailed CommitHash) where + render (P.Detailed commitHash) = + P.styled [P.color P.Yellow] $ + P.render (toText commitHash) + +instance P.Render (P.Summarized CommitHash) where + render (P.Summarized commitHash) = + P.styled [P.color P.Yellow] $ + P.render (toShortText commitHash) diff --git a/app/History/CommitInfo.hs b/app/History/CommitInfo.hs index c5224b2..2c861a6 100644 --- a/app/History/CommitInfo.hs +++ b/app/History/CommitInfo.hs @@ -20,7 +20,7 @@ import History.PartialCommitInfo (PartialCommitInfo (..)) import Issue (Issue (..)) import Issue.Provenance qualified as I import Parallel (parSequence) -import Patch qualified as P +import Patch qualified as A import Process (sh) import System.FilePath ((</>)) import System.IO.Temp (withSystemTempDirectory) @@ -110,7 +110,7 @@ diffCommitInfos maybeOldInfo newInfo = let cwd = tmp T.writeFile (tmp </> "old") old T.writeFile (tmp </> "new") new - P.parse . LT.toStrict . LT.decodeUtf8 <$> sh ("git diff --no-index -- old new || :" & setWorkingDir cwd) + A.parse . LT.toStrict . LT.decodeUtf8 <$> sh ("git diff --no-index -- old new || :" & setWorkingDir cwd) mergeListsBy :: (a -> a -> Bool) -> (a -> a -> b) -> (a -> b) -> (a -> b) -> [a] -> [a] -> [b] mergeListsBy eq onBoth onLeft onRight lefts rights = diff --git a/app/History/IssueEvent.hs b/app/History/IssueEvent.hs index 0900f13..93bd133 100644 --- a/app/History/IssueEvent.hs +++ b/app/History/IssueEvent.hs @@ -2,7 +2,10 @@ module History.IssueEvent (IssueEvent (..)) where import History.CommitHash (CommitHash) import Issue (Issue) +import Issue.Render qualified as I import Patch (Patch) +import Render ((<<<)) +import Render qualified as P data IssueEvent = IssueCreated @@ -22,3 +25,28 @@ data IssueEvent patch :: Patch } deriving (Show) + +instance P.Render IssueEvent where + render = P.render . P.Detailed + +instance P.Render (P.Detailed IssueEvent) where + render (P.Detailed issueEvent) = + P.Summarized issueEvent + <<< P.hardline @P.AnsiStyle + <<< issueEvent.patch + +instance P.Render (P.Summarized IssueEvent) where + render (P.Summarized issueEvent) = + case issueEvent of + IssueCreated {hash, issue} -> + P.Summarized hash + <<< P.styled [P.color P.Green] "created" + <<< I.IssueTitle issue + IssueChanged {hash, issue} -> + P.Summarized hash + <<< P.styled [P.color P.Green] "changed" + <<< I.IssueTitle issue + IssueDeleted {hash, issue} -> + P.Summarized hash + <<< P.styled [P.color P.Green] "deleted" + <<< I.IssueTitle issue |