From ea1236f2cf6d3ef4b739b2ca28f47a3bbed42295 Mon Sep 17 00:00:00 2001 From: Alexander Foremny Date: Tue, 17 Oct 2023 14:14:48 +0200 Subject: refactor history --- app/History/CommitHash.hs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 app/History/CommitHash.hs (limited to 'app/History/CommitHash.hs') 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 = "" +toShortText (Commit hash) = T.take 7 hash + +toText :: CommitHash -> T.Text +toText WorkingTree = "" +toText (Commit hash) = hash -- cgit v1.2.3