aboutsummaryrefslogtreecommitdiffstats
path: root/app/History/CommitHash.hs
blob: 3fcbb9033df48698e62fe60143e636bcbfad06e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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