aboutsummaryrefslogtreecommitdiff
path: root/CabalHelper/Compile.hs
diff options
context:
space:
mode:
Diffstat (limited to 'CabalHelper/Compile.hs')
-rw-r--r--CabalHelper/Compile.hs11
1 files 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 "\