Permalink
Browse files

Fix for broken git commits

The problem was that by setting the Environment through runProcess, the
current environment gets eradicated. This causes git to bail out. The
fix is simple: query the current environment and append any additional
variables.
  • Loading branch information...
1 parent 8aa4811 commit 0772638735d363a09f6ef415258e8c9ff2c161e5 Jochen Keil committed Mar 16, 2013
Showing with 5 additions and 2 deletions.
  1. +5 −2 Data/FileStore/Utils.hs
View
@@ -27,7 +27,8 @@ module Data.FileStore.Utils (
, encodeArg ) where
import Control.Exception (throwIO)
-import Control.Monad (liftM, when, unless)
+import Control.Applicative ((<$>))
+import Control.Monad (liftM, liftM2, when, unless)
import Data.ByteString.Lazy.UTF8 (toString)
import Data.Char (isSpace)
import Data.List (intersect, nub, isPrefixOf, isInfixOf)
@@ -39,6 +40,7 @@ import System.FilePath ((</>), takeDirectory)
import System.IO (openTempFile, hClose)
import System.IO.Error (isDoesNotExistError)
import System.Process (runProcess, waitForProcess)
+import System.Environment (getEnvironment)
import qualified Data.ByteString.Lazy as B
import qualified Data.ByteString as S
import qualified Control.Exception as E
@@ -68,7 +70,8 @@ runShellCommand workingDir environment command optionList = do
tempPath <- E.catch getTemporaryDirectory (\(_ :: E.SomeException) -> return ".")
(outputPath, hOut) <- openTempFile tempPath "out"
(errorPath, hErr) <- openTempFile tempPath "err"
- hProcess <- runProcess (encodeArg command) (map encodeArg optionList) (Just workingDir) environment Nothing (Just hOut) (Just hErr)
+ env <- liftM2 (++) environment . Just <$> getEnvironment
+ hProcess <- runProcess (encodeArg command) (map encodeArg optionList) (Just workingDir) env Nothing (Just hOut) (Just hErr)
status <- waitForProcess hProcess
errorOutput <- S.readFile errorPath
output <- S.readFile outputPath

0 comments on commit 0772638

Please sign in to comment.