packages feed

yesod-gitrev 0.2.1 → 0.2.2

raw patch · 5 files changed

+44/−5 lines, 5 filesdep +processPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependencies added: process

API changes (from Hackage documentation)

- Yesod.GitRev: tGitRev :: Q (TExp GitRev)
+ Yesod.GitRev: tGitRev :: TSpliceable GitRev

Files

README.md view
@@ -1,6 +1,6 @@ A subsite for displaying git information. -[![Hackage](https://img.shields.io/hackage/v/yesod-gitrev.svg)](https://hackage.haskell.org/package/yesod-gitrev) [![Build Status](https://travis-ci.org/DanBurton/yesod-gitrev.svg)](https://travis-ci.org/DanBurton/yesod-gitrev)+[![Hackage](https://img.shields.io/hackage/v/yesod-gitrev.svg)](https://hackage.haskell.org/package/yesod-gitrev)  You can use the `gitRev` splice (or `tGitRev` typed splice) to generate a value of type `GitRev`.
examples/ExampleMain.hs view
@@ -12,7 +12,11 @@  import Yesod.Core import Yesod.GitRev+import ExampleTH (ensureGitContext) +-- In case this is tested outside of a git context+$ensureGitContext+ data Master = Master   { getGitRev :: GitRev   }@@ -25,3 +29,6 @@  main :: IO () main = warp 3000 $ Master $$(tGitRev)++main2 :: IO ()+main2 = warp 3000 $ Master $(gitRev)
+ examples/ExampleTH.hs view
@@ -0,0 +1,9 @@+module ExampleTH (ensureGitContext) where++import Language.Haskell.TH (Q, runIO, Dec)+import System.Process (callProcess)++ensureGitContext :: Q [Dec]+ensureGitContext = runIO $ do+  callProcess "git" ["init", "--quiet"]+  return []
src/Yesod/GitRev/Data.hs view
@@ -2,13 +2,20 @@ {-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE QuasiQuotes #-} {-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE CPP #-}  module Yesod.GitRev.Data where  import GitHash-import Language.Haskell.TH.Syntax (Lift, Q, TExp, Exp, unTypeQ)+import Language.Haskell.TH.Syntax (Lift, Q, Exp, unTypeQ) import Yesod.Core +#if MIN_VERSION_GLASGOW_HASKELL(9,0,0,0)+import Language.Haskell.TH (Code, examineCode)+#else+import Language.Haskell.TH.Syntax(TExp)+#endif+ -- | You should not construct one of these yourself. -- Instead, use gitRev or tGitRev. -- Fields added to this record are treated as a minor version bump.@@ -25,19 +32,32 @@   }   deriving Lift +type TSpliceable a =+#if MIN_VERSION_GLASGOW_HASKELL(9,0,0,0)+  Code Q a+#else+  Q (TExp a)+#endif+ mkYesodSubData "GitRev" [parseRoutes| / GitRevR GET |]  -- | A typed splice for creating a GitRev. -- Example: $$(tGitRev) :: GitRev-tGitRev :: Q (TExp GitRev)+tGitRev :: TSpliceable GitRev tGitRev = [|| gitRevFromGitInfo $$(tGitInfoCwd) ||]  -- | An untyped splice for creating a GitRev. -- Example: $(gitRev) :: GitRev gitRev :: Q Exp-gitRev = unTypeQ tGitRev+gitRev = unTypeQ . examine $ tGitRev+  where+#if MIN_VERSION_GLASGOW_HASKELL(9,0,0,0)+    examine = examineCode+#else+    examine = id+#endif  -- This function is considered to be "internal". -- Changes to this function will not be accounted for in minor version bumps.
yesod-gitrev.cabal view
@@ -1,5 +1,5 @@ name:                yesod-gitrev-version:             0.2.1+version:             0.2.2 synopsis:   A subsite for displaying git information. author:              Dan Burton@@ -43,10 +43,13 @@   main-is: TestExamples.hs   build-depends:       base+    , template-haskell+    , process     , yesod-core     , yesod-gitrev   other-modules:       ExampleMain+      ExampleTH   default-language: Haskell2010