From 872ff1eae6ff58851361de9335fc1d82539b66f7 Mon Sep 17 00:00:00 2001 From: Michael Sloan Date: Wed, 4 May 2016 14:47:49 -0700 Subject: [PATCH] Make hpack default to only outputting warnings #2011 --- src/Stack/Package.hs | 16 +++++++++++++--- stack-7.8.yaml | 2 +- stack-8.0.yaml | 2 +- stack.cabal | 2 +- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/Stack/Package.hs b/src/Stack/Package.hs index 666d11f6ef..bd4445f840 100644 --- a/src/Stack/Package.hs +++ b/src/Stack/Package.hs @@ -42,7 +42,7 @@ import Prelude.Compat import Control.Arrow ((&&&)) import Control.Exception hiding (try,catch) -import Control.Monad (liftM, liftM2, (<=<), when, forM) +import Control.Monad (liftM, liftM2, (<=<), when, forM, forM_) import Control.Monad.Catch import Control.Monad.IO.Class import Control.Monad.Logger @@ -1125,8 +1125,18 @@ hpack pkgDir = do when exists $ do let fpt = T.pack (toFilePath hpackFile) $logDebug $ "Running hpack on " <> fpt - liftIO $ Hpack.hpack (toFilePath pkgDir) True - $logDebug $ "Done running hpack on " <> fpt + r <- liftIO $ Hpack.hpackResult (toFilePath pkgDir) + forM_ (Hpack.resultWarnings r) $ \w -> $logWarn ("WARNING: " <> T.pack w) + let cabalFile = T.pack (Hpack.resultCabalFile r) + case Hpack.resultStatus r of + Hpack.Generated -> $logDebug $ + "hpack generated a modified version of " <> cabalFile + Hpack.OutputUnchanged -> $logDebug $ + "hpack output unchanged in " <> cabalFile + -- NOTE: this is 'logInfo' so it will be outputted to the + -- user by default. + Hpack.AlreadyGeneratedByNewerHpack -> $logWarn $ + "WARNING: " <> cabalFile <> " was generated with a newer version of hpack, please upgrade and try again." -- | Path for the package's build log. buildLogPath :: (MonadReader env m, HasBuildConfig env, MonadThrow m) diff --git a/stack-7.8.yaml b/stack-7.8.yaml index 5dce00f3fb..3445cee280 100644 --- a/stack-7.8.yaml +++ b/stack-7.8.yaml @@ -31,7 +31,7 @@ extra-deps: - process-1.2.1.0 - time-1.5.0.1 - base-compat-0.9.0 -- hpack-0.10.0 +- hpack-0.14.0 - microlens-0.4.1.0 - open-browser-0.2.1.0 - tls-1.3.5 diff --git a/stack-8.0.yaml b/stack-8.0.yaml index 176a4299dc..b7be0bf2cf 100644 --- a/stack-8.0.yaml +++ b/stack-8.0.yaml @@ -19,7 +19,7 @@ nix: packages: - zlib extra-deps: -- hpack-0.12.0 +- hpack-0.14.0 - path-0.5.7 - path-io-1.1.0 - transformers-0.5.2.0 diff --git a/stack.cabal b/stack.cabal index 7de3ab8a09..3be99d657c 100644 --- a/stack.cabal +++ b/stack.cabal @@ -218,7 +218,7 @@ library , hastache , project-template >= 0.2 , zip-archive - , hpack >= 0.10.0 && < 0.15 + , hpack >= 0.14.0 && < 0.15 if os(windows) cpp-options: -DWINDOWS build-depends: Win32