    {-# LANGUAGE CPP             #-}
    {-# LANGUAGE TemplateHaskell #-}

    #if __GLASGOW_HASKELL__ >= 900
    {-# OPTIONS_GHC -Wno-overlapping-patterns #-}
    #endif

    module Agda.VersionCommit where

    import Development.GitRev

    import Agda.Version

    versionWithCommitInfo :: String
    versionWithCommitInfo :: [Char]
    versionWithCommitInfo = [Char]
    version [Char] -> [Char] -> [Char]
    forall a. [a] -> [a] -> [a]
    ++ [Char] -> ([Char] -> [Char]) -> Maybe [Char] -> [Char]
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe [Char]
    "" ([Char]
    "-" [Char] -> [Char] -> [Char]
    forall a. [a] -> [a] -> [a]
    ++) Maybe [Char]
    commitInfo

    -- | Information about current git commit, generated at compile time
    commitInfo :: Maybe String
    commitInfo :: Maybe [Char]
    commitInfo
      | [Char]
    hash [Char] -> [Char] -> Bool
    forall a. Eq a => a -> a -> Bool
    == [Char]
    "UNKNOWN" = Maybe [Char]
    forall a. Maybe a
    Nothing
      | Bool
    otherwise         = [Char] -> Maybe [Char]
    forall a. a -> Maybe a
    Just ([Char] -> Maybe [Char]) -> [Char] -> Maybe [Char]
    forall a b. (a -> b) -> a -> b
    $ [Char] -> [Char]
    forall {a}. [a] -> [a]
    abbrev [Char]
    hash [Char] -> [Char] -> [Char]
    forall a. [a] -> [a] -> [a]
    ++ [Char]
    dirty
      where
        hash :: [Char]
    hash = $(gitHash)

        -- Check if any tracked files have uncommitted changes
        dirty :: [Char]
    dirty | $(gitDirtyTracked) = [Char]
    "-dirty"
              | Bool
    otherwise          = [Char]
    ""

        -- Abbreviate a commit hash while keeping it unambiguous
        abbrev :: [a] -> [a]
    abbrev = Int -> [a] -> [a]
    forall a. Int -> [a] -> [a]
    take Int
    7