packages feed

githash 0.1.1.0 → 0.1.2.0

raw patch · 3 files changed

+36/−3 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ GitHash: tGitInfoCwdTry :: Q (TExp (Either String GitInfo))
+ GitHash: tGitInfoTry :: FilePath -> Q (TExp (Either String GitInfo))

Files

ChangeLog.md view
@@ -1,5 +1,9 @@ # ChangeLog for githash +## 0.1.2.0++* Add `tGitInfoTry` and `tGitInfoCwdTry`+ ## 0.1.1.0  * Add message of the most recent commit
githash.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: 380f229f7ff7b7cb44366114b73ff9012ed62bf5baef879380562b3c56ed80e9+-- hash: 2b87276bb2ac5b00efe63f26346081485fe2d35e29770fcceb6fa7ab6f1fd414  name:           githash-version:        0.1.1.0+version:        0.1.2.0 synopsis:       Compile git revision info into Haskell projects description:    Please see the README and documentation at <https://www.stackage.org/package/githash> category:       Development
src/GitHash.hs view
@@ -52,6 +52,8 @@     -- * Template Haskell   , tGitInfo   , tGitInfoCwd+  , tGitInfoTry+  , tGitInfoCwdTry   ) where  import Control.Applicative@@ -197,7 +199,7 @@ instance Exception GitHashException  -- | Load up the 'GitInfo' value at compile time for the given--- directory.+-- directory. Compilation fails if no info is available. -- -- @since 0.1.0.0 tGitInfo :: FilePath -> Q (TExp GitInfo)@@ -210,9 +212,36 @@   mapM_ addDependentFile (_giFiles gi)   lift (gi :: GitInfo) -- adding type sig to make the unsafe look slightly better +-- | Try to load up the 'GitInfo' value at compile time for the given+-- directory.+--+-- @since 0.1.2.0+tGitInfoTry :: FilePath -> Q (TExp (Either String GitInfo))+tGitInfoTry fp = unsafeTExpCoerce $ do+  egi <- runIO $ do+    eroot <- getGitRoot fp+    case eroot of+      Left e -> return $ Left $ show e+      Right root -> do+        einfo <- getGitInfo root+        case einfo of+          Left e -> return $ Left $ show e+          Right info -> return $ Right info+  case egi of+    Left _ -> return ()+    Right gi -> mapM_ addDependentFile (_giFiles gi)+  lift (egi :: Either String GitInfo) -- adding type sig to make the unsafe look slightly better+ -- | Load up the 'GitInfo' value at compile time for the current -- working directory. -- -- @since 0.1.0.0 tGitInfoCwd :: Q (TExp GitInfo) tGitInfoCwd = tGitInfo "."++-- | Try to load up the 'GitInfo' value at compile time for the current+-- working directory.+--+-- @since 0.1.2.0+tGitInfoCwdTry :: Q (TExp (Either String GitInfo))+tGitInfoCwdTry = tGitInfoTry "."