From a8551e48ccb189202d8c7aa587c50044d7c41471 Mon Sep 17 00:00:00 2001 From: Daniel Gröber Date: Mon, 12 Jun 2017 04:23:44 +0200 Subject: Fix unpackCabalHEAD again due to old 'process' --- CabalHelper/Compile.hs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/CabalHelper/Compile.hs b/CabalHelper/Compile.hs index 5071e15..2d0007d 100644 --- a/CabalHelper/Compile.hs +++ b/CabalHelper/Compile.hs @@ -375,9 +375,16 @@ unpackCabalHEAD tmpdir = do let dir = tmpdir "cabal-head.git" url = "https://github.com/haskell/cabal.git" ExitSuccess <- rawSystem "git" [ "clone", "--depth=1", url, dir] - let git_rev_parse = (proc "git" ["rev-parse", "HEAD"]) { cwd = Just dir } - commit <- trim <$> readCreateProcess git_rev_parse "" + commit <- + withDirectory_ dir $ trim <$> readProcess "git" ["rev-parse", "HEAD"] "" return (dir "Cabal", commit) + where + withDirectory_ :: FilePath -> IO a -> IO a + withDirectory_ dir action = + bracket + (liftIO getCurrentDirectory) + (liftIO . setCurrentDirectory) + (\_ -> liftIO (setCurrentDirectory dir) >> action) errorInstallCabal :: Version -> FilePath -> a errorInstallCabal cabalVer _distdir = panic $ printf "\ -- cgit v1.2.3