From 5fb671eefe0186e8ff15886f0d968804b9c91ba5 Mon Sep 17 00:00:00 2001 From: patrick brisbin Date: Wed, 31 Jul 2024 12:42:03 -0400 Subject: [PATCH 1/3] Ensure we still log when using --dry-run --- src/Restyler/Restyler/Run.hs | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/Restyler/Restyler/Run.hs b/src/Restyler/Restyler/Run.hs index 9e6fc864..2390f419 100644 --- a/src/Restyler/Restyler/Run.hs +++ b/src/Restyler/Restyler/Run.hs @@ -342,20 +342,22 @@ dockerRunRestyler r@Restyler {..} WithProgress {..} = do [path] -> pack path paths -> show (length paths) <> " paths" - ec <- - if dryRun - then pure ExitSuccess - else case pItem of - DockerRunPathToStdout path -> do - logRunningOn [path] - (ec, out) <- dockerRunStdout $ args <> [prefix path] - ec <$ writeFile path (fixNewline out) - DockerRunPathsOverwrite sep paths -> do - logRunningOn paths - dockerRun $ args <> ["--" | sep] <> map prefix paths - DockerRunPathOverwrite sep path -> do - logRunningOn [path] - dockerRun $ args <> ["--" | sep] <> [prefix path] + unlessDryRun f + | dryRun = pure ExitSuccess + | otherwise = f + + ec <- case pItem of + DockerRunPathToStdout path -> do + logRunningOn [path] + unlessDryRun $ do + (ec, out) <- dockerRunStdout $ args <> [prefix path] + ec <$ writeFile path (fixNewline out) + DockerRunPathsOverwrite sep paths -> do + logRunningOn paths + unlessDryRun $ dockerRun $ args <> ["--" | sep] <> map prefix paths + DockerRunPathOverwrite sep path -> do + logRunningOn [path] + unlessDryRun $ dockerRun $ args <> ["--" | sep] <> [prefix path] case ec of ExitSuccess -> pure () From 28d9517a89ede3be5bd46d8c28e33e5257d5198f Mon Sep 17 00:00:00 2001 From: patrick brisbin Date: Wed, 31 Jul 2024 12:26:25 -0400 Subject: [PATCH 2/3] Fail with specific exit-code on differences --- src/Restyler/CLI.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Restyler/CLI.hs b/src/Restyler/CLI.hs index 37d13699..60e69b04 100644 --- a/src/Restyler/CLI.hs +++ b/src/Restyler/CLI.hs @@ -32,7 +32,7 @@ main withApp run = do failOnDifferences <- getFailOnDifferences if failOnDifferences - then ExitFailure 1 <$ logError "Differences found" + then ExitFailure 228 <$ logError "Differences found" else ExitSuccess <$ logWarn "Differences found" exitHandler :: MonadLogger m => AnnotatedException SomeException -> m ExitCode From 526d4d147fc8d597c7a9d1882353db401a969ca9 Mon Sep 17 00:00:00 2001 From: patrick brisbin Date: Wed, 31 Jul 2024 12:43:09 -0400 Subject: [PATCH 3/3] Version bump --- package.yaml | 2 +- restyler.cabal | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.yaml b/package.yaml index a95b74a3..b240dd62 100644 --- a/package.yaml +++ b/package.yaml @@ -1,5 +1,5 @@ name: restyler -version: 0.4.2.0 +version: 0.4.2.1 license: MIT language: GHC2021 diff --git a/restyler.cabal b/restyler.cabal index d6c5482b..5bcdb66e 100644 --- a/restyler.cabal +++ b/restyler.cabal @@ -5,7 +5,7 @@ cabal-version: 1.12 -- see: https://github.com/sol/hpack name: restyler -version: 0.4.2.0 +version: 0.4.2.1 license: MIT license-file: LICENSE build-type: Simple