diff --git a/cabal-install/src/Distribution/Client/ProjectConfig.hs b/cabal-install/src/Distribution/Client/ProjectConfig.hs index 766f35e50aedc991a3eae1a9e5b1686b19d2e04d..2b78c16449df592e9e149e6f4ff83e4d890bd59f 100644 --- a/cabal-install/src/Distribution/Client/ProjectConfig.hs +++ b/cabal-install/src/Distribution/Client/ProjectConfig.hs @@ -1192,7 +1192,7 @@ syncAndReadSourcePackagesRemoteRepos verbosity for_ repoGroupWithPaths $ \(repo, _, repoPath) -> for_ (nonEmpty (srpCommand repo)) $ \(cmd :| args) -> liftIO $ do exitCode <- rawSystemIOWithEnv verbosity cmd args (Just repoPath) Nothing Nothing Nothing Nothing - unless (exitCode /= ExitSuccess) $ exitWith exitCode + unless (exitCode == ExitSuccess) $ exitWith exitCode -- But for reading we go through each 'SourceRepo' including its subdir -- value and have to know which path each one ended up in. diff --git a/cabal-testsuite/PackageTests/postCheckoutCommand/cabal.negative.project b/cabal-testsuite/PackageTests/postCheckoutCommand/cabal.negative.project new file mode 100644 index 0000000000000000000000000000000000000000..0100cb0075b08027fbb8fa00a9885e8263af1b56 --- /dev/null +++ b/cabal-testsuite/PackageTests/postCheckoutCommand/cabal.negative.project @@ -0,0 +1,8 @@ +packages: . + +source-repository-package + type: git +-- A Sample repo to test post-checkout-command + location: https://github.com/haskell/bytestring + post-checkout-command: false +-- https://en.wikipedia.org/wiki/True_and_false_(commands) diff --git a/cabal-testsuite/PackageTests/postCheckoutCommand/cabal.out b/cabal-testsuite/PackageTests/postCheckoutCommand/cabal.out new file mode 100644 index 0000000000000000000000000000000000000000..8165f4408ffde650575055397e8f77058a86d26a --- /dev/null +++ b/cabal-testsuite/PackageTests/postCheckoutCommand/cabal.out @@ -0,0 +1,2 @@ +# cabal v2-build +# cabal v2-build diff --git a/cabal-testsuite/PackageTests/postCheckoutCommand/cabal.positive.project b/cabal-testsuite/PackageTests/postCheckoutCommand/cabal.positive.project new file mode 100644 index 0000000000000000000000000000000000000000..a4f1e08217fd6bd0aab3c0888ad9a871c902e622 --- /dev/null +++ b/cabal-testsuite/PackageTests/postCheckoutCommand/cabal.positive.project @@ -0,0 +1,8 @@ +packages: . + +source-repository-package + type: git +-- A Sample repo to test post-checkout-command + location: https://github.com/haskell/bytestring + post-checkout-command: true +-- https://en.wikipedia.org/wiki/True_and_false_(commands) diff --git a/cabal-testsuite/PackageTests/postCheckoutCommand/cabal.test.hs b/cabal-testsuite/PackageTests/postCheckoutCommand/cabal.test.hs new file mode 100644 index 0000000000000000000000000000000000000000..d63ae822ead74847a6746f4ec14599c5a3ba4127 --- /dev/null +++ b/cabal-testsuite/PackageTests/postCheckoutCommand/cabal.test.hs @@ -0,0 +1,8 @@ +import Test.Cabal.Prelude + +main = cabalTest $ do + skipIfWindows + withProjectFile "cabal.positive.project" $ do + cabal "v2-build" ["-v0"] + withProjectFile "cabal.negative.project" $ do + fails $ cabal "v2-build" ["-v0"] diff --git a/cabal-testsuite/PackageTests/postCheckoutCommand/example.cabal b/cabal-testsuite/PackageTests/postCheckoutCommand/example.cabal new file mode 100644 index 0000000000000000000000000000000000000000..c2d440f844bdafeada3d1b9d34e57a3cb0628b2c --- /dev/null +++ b/cabal-testsuite/PackageTests/postCheckoutCommand/example.cabal @@ -0,0 +1,9 @@ +cabal-version: 2.4 +name: example +version: 1.0 + +library + exposed-modules: Example + build-depends: base + hs-source-dirs: src + default-language: Haskell2010 diff --git a/cabal-testsuite/PackageTests/postCheckoutCommand/src/Example.hs b/cabal-testsuite/PackageTests/postCheckoutCommand/src/Example.hs new file mode 100644 index 0000000000000000000000000000000000000000..113f4de157ff80f2757153d6b96f6ef959637d88 --- /dev/null +++ b/cabal-testsuite/PackageTests/postCheckoutCommand/src/Example.hs @@ -0,0 +1,4 @@ +module Example (someFunc) where + +someFunc :: IO () +someFunc = putStrLn "Example" diff --git a/changelog.d/issue-7641 b/changelog.d/issue-7641 new file mode 100644 index 0000000000000000000000000000000000000000..c6c553985033b21391a8cdf04194454f0197875e --- /dev/null +++ b/changelog.d/issue-7641 @@ -0,0 +1,4 @@ +synopsis: Fix post-checkout-command crash when 0 exit status bug +issues: #7641 +packages: cabal-install +prs: #7847 \ No newline at end of file