@@ -43,7 +43,7 @@ import Data.Conduit.Zlib (ungzip)
4343import qualified Data.Foldable as F
4444import Data.Map (Map )
4545import qualified Data.Map as Map
46- import Data.Maybe (fromMaybe , isJust , mapMaybe )
46+ import Data.Maybe (fromMaybe , mapMaybe )
4747import Data.Monoid (mempty , (<>) )
4848import Data.Set (Set )
4949import qualified Data.Set as Set
@@ -64,15 +64,14 @@ import Distribution.ParseUtils (PError)
6464import qualified Distribution.Text as DT
6565import Network.HTTP.Download
6666import Path (mkRelDir , parent ,
67- parseAbsFile ,
6867 parseRelDir , toFilePath ,
6968 (</>) )
7069import Stack.Types
7170import System.Directory
7271import System.FilePath (takeBaseName , (<.>) )
7372import System.IO (IOMode (ReadMode , WriteMode ),
7473 withBinaryFile )
75- import System.Process.Read (runIn , EnvOverride )
74+ import System.Process.Read (runIn , EnvOverride , doesExecutableExist )
7675
7776-- | A cabal file with name and version parsed from the filepath, and the
7877-- package description itself ready to be parsed. It's left in unparsed form
@@ -275,12 +274,7 @@ updateIndexGit menv = do
275274 let tarFile = configPackageIndex config
276275 idxPath = parent tarFile
277276 liftIO (createDirectoryIfMissing True (toFilePath idxPath))
278- path <- liftIO (findExecutable " git" )
279- case path of
280- Nothing ->
281- error " Please install git and provide the executable on your PATH"
282- Just fp ->
283- do gitPath <- parseAbsFile fp
277+ do
284278 gitUrl <- askPackageIndexGitUrl
285279 repoName <- parseRelDir $ takeBaseName $ T. unpack gitUrl
286280 let cloneArgs =
@@ -300,13 +294,13 @@ updateIndexGit menv = do
300294 liftIO (doesDirectoryExist (toFilePath acfDir))
301295 unless repoExists
302296 (do $ logInfo (" Cloning repository for first from " <> gitUrl)
303- runIn suDir gitPath menv cloneArgs Nothing )
304- runIn acfDir gitPath menv [" fetch" ," --tags" ," --depth=1" ] Nothing
297+ runIn suDir " git " menv cloneArgs Nothing )
298+ runIn acfDir " git " menv [" fetch" ," --tags" ," --depth=1" ] Nothing
305299 _ <-
306300 (liftIO . tryIO) (removeFile (toFilePath tarFile))
307301 when (configGpgVerifyIndex config)
308302 (do runIn acfDir
309- gitPath
303+ " git "
310304 menv
311305 [" tag" ," -v" ," current-hackage" ]
312306 (Just (unlines [" Signature verification failed. "
@@ -318,7 +312,7 @@ updateIndexGit menv = do
318312 (T. pack . toFilePath) tarFile)
319313 deleteCache
320314 runIn acfDir
321- gitPath
315+ " git "
322316 menv
323317 [" archive"
324318 ," --format=tar"
@@ -377,9 +371,7 @@ getPkgVersions menv pkg = do
377371isGitInstalled :: MonadIO m -- FIXME use the EnvOverride for finding git
378372 => EnvOverride
379373 -> m Bool
380- isGitInstalled _FIXMEunused =
381- return . isJust =<<
382- liftIO (findExecutable " git" )
374+ isGitInstalled = flip doesExecutableExist " git"
383375
384376-- | Delete the package index cache
385377deleteCache :: (MonadIO m , MonadReader env m , HasConfig env , MonadLogger m ) => m ()
0 commit comments