~jojo/Carth

2de385800cd40b59544116f0a27c5615d4231a17 — JoJo 1 year, 6 months ago af54e01
Actually, do remove showing git commit in version

Idk it's just bothersome to package
2 files changed, 2 insertions(+), 21 deletions(-)

M app/GetConfig.hs
M app/Prebaked.hs
M app/GetConfig.hs => app/GetConfig.hs +0 -5
@@ 141,11 141,6 @@ printVersion = do
    let (major, minor, patch) = version
    let versionStr = concat [show major, ".", show minor, ".", show patch]
    putStrLn ("Carth " ++ versionStr)
    putStrLn ("git: " ++ commitHash ++ " (" ++ commitDate ++ ")")

version :: (Int, Int, Int)
version = $(readCompilerVersion)

commitHash :: String
commitDate :: String
(commitHash, commitDate) = $(getCommit)

M app/Prebaked.hs => app/Prebaked.hs +2 -16
@@ 1,13 1,12 @@
module Prebaked (readCompilerVersion, getCommit) where
module Prebaked (readCompilerVersion) where

import Language.Haskell.TH
import Language.Haskell.TH.Syntax (Lift(..), qAddDependentFile)
import Language.Haskell.TH.Syntax (Lift(..))
import Data.Maybe
import qualified Text.Megaparsec as M
import qualified Text.Megaparsec.Char as MC
import qualified Text.Megaparsec.Char.Lexer as ML
import Data.Void
import System.Process

type Parser = M.Parsec Void String



@@ 29,16 28,3 @@ pversion = do
  where
    num = ML.decimal
    dot = MC.char '.'

getCommit :: Q Exp
getCommit =
    qAddDependentFile ".git/index"
        >> runIO
            (do
                c <- fmap (head . lines)
                    $ readProcess "git" ["rev-parse", "--short", "HEAD"] ""
                d <- fmap (head . lines)
                    $ readProcess "git" ["show", "-s", "--format=%ci", c] ""
                pure (c, d)
            )
        >>= lift