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.hs23
1 files changed, 23 insertions, 0 deletions
diff --git a/app/History/CommitHash.hs b/app/History/CommitHash.hs
new file mode 100644
index 0000000..3fcbb90
--- /dev/null
+++ b/app/History/CommitHash.hs
@@ -0,0 +1,23 @@
+module History.CommitHash
+ ( CommitHash (..),
+ toShortText,
+ toText,
+ )
+where
+
+import Data.Binary (Binary)
+import Data.Text qualified as T
+import GHC.Generics (Generic)
+
+data CommitHash
+ = WorkingTree
+ | Commit T.Text
+ deriving (Show, Binary, Generic)
+
+toShortText :: CommitHash -> T.Text
+toShortText WorkingTree = "<dirty>"
+toShortText (Commit hash) = T.take 7 hash
+
+toText :: CommitHash -> T.Text
+toText WorkingTree = "<dirty>"
+toText (Commit hash) = hash