aboutsummaryrefslogtreecommitdiffstats
path: root/app/History/CommitHash.hs
diff options
context:
space:
mode:
Diffstat (limited to 'app/History/CommitHash.hs')
-rw-r--r--app/History/CommitHash.hs16
1 files changed, 8 insertions, 8 deletions
diff --git a/app/History/CommitHash.hs b/app/History/CommitHash.hs
index cbe4db1..1075b2f 100644
--- a/app/History/CommitHash.hs
+++ b/app/History/CommitHash.hs
@@ -6,6 +6,7 @@ module History.CommitHash
where
import Data.Binary (Binary)
+import Data.Maybe (fromMaybe)
import Data.Text qualified as T
import GHC.Generics (Generic)
import Render qualified as P
@@ -15,13 +16,12 @@ data CommitHash
| Commit T.Text
deriving (Eq, Show, Binary, Generic)
-toShortText :: CommitHash -> T.Text
-toShortText WorkingTree = "<dirty>"
-toShortText (Commit hash) = T.take 7 hash
+toShortText :: CommitHash -> Maybe T.Text
+toShortText = fmap (T.take 7) . toText
-toText :: CommitHash -> T.Text
-toText WorkingTree = "<dirty>"
-toText (Commit hash) = hash
+toText :: CommitHash -> Maybe T.Text
+toText WorkingTree = Nothing
+toText (Commit hash) = Just hash
instance P.Render CommitHash where
render = P.render . P.Detailed
@@ -29,9 +29,9 @@ instance P.Render CommitHash where
instance P.Render (P.Detailed CommitHash) where
render (P.Detailed commitHash) =
P.styled [P.color P.Yellow] $
- P.render (toText commitHash)
+ P.render (fromMaybe "<dirty>" (toText commitHash))
instance P.Render (P.Summarized CommitHash) where
render (P.Summarized commitHash) =
P.styled [P.color P.Yellow] $
- P.render (toShortText commitHash)
+ P.render (fromMaybe "<dirty>" (toShortText commitHash))