{- This file is part of Vervis.
 -
 - Written in 2016 by fr33domlover <fr33domlover@riseup.net>.
 -
 - ♡ Copying is an act of love. Please copy, reuse and share.
 -
 - The author(s) have dedicated all copyright and related and neighboring
 - rights to this software to the public domain worldwide. This software is
 - distributed without any warranty.
 -
 - You should have received a copy of the CC0 Public Domain Dedication along
 - with this software. If not, see
 - <http://creativecommons.org/publicdomain/zero/1.0/>.
 -}

module Data.Revision.Local
    ( Change (..)
    , Revision (..)
    , Version (..)
    )
where

import Prelude

import Data.Text (Text)
import Data.Time.Clock (UTCTime)

-- | A recorded patch or tag.
data Change = Change
    { -- | When it was recorded.
      cgTime  :: UTCTime
      -- | Lowercase hex representation of its SHA1 info hash.
    , cgHash  :: Text
      -- | Single-line title.
    , cgTitle :: Text
    }

-- | Given a non-empty repo, this refers to a point in its history.
data Revision
    -- | The last change is a tag.
    = RevTag Change
    -- | The last change isn't a tag, but a tag exists earlier in the history.
    -- Specifies details of the last tag, the number of patches after that tag,
    -- and details of the last patch.
    | RevTagPlus Change Int Change
    -- | There are no recorded tags. Specifies the last patch.
    | RevPatch Change

data Version = Version
    { verSharer   :: Text
    , verRepo     :: Text
    , verChanges  :: Int
    , verRevision :: Revision
    }