1module Stackage.CheckPlan
5import Control.Monad (unless, when)
6import Data.List (isPrefixOf, sort)
7import qualified Data.Map as Map
8import qualified Data.Set as Set
9import Stackage.InstallInfo
12import System.Exit (ExitCode (ExitFailure, ExitSuccess),
14import System.Process (readProcessWithExitCode)
15import Stackage.CheckCabalVersion (checkCabalVersion)
17data Mismatch = OnlyDryRun String | OnlySimpleList String
20checkPlan :: BuildPlan -> IO ()
22 _ <- checkCabalVersion
24 putStrLn "Checking build plan"
25 (ec, dryRun', stderr) <- readProcessWithExitCode "cabal" (addCabalArgsOnlyGlobal $ "install":"--dry-run":bpPackageList bp) ""
26 when (ec /= ExitSuccess || "Warning:" `isPrefixOf` stderr) $ do
29 putStrLn "cabal returned a bad result, exiting"
31 let dryRun = sort $ filter notOptionalCore $ map (takeWhile (/= ' ')) $ drop 2 $ lines dryRun'
32 let mismatches = getMismatches dryRun (filter notOptionalCore $ bpPackageList bp)
33 unless (null mismatches) $ do
34 putStrLn "Found the following mismatches"
35 mapM_ print mismatches
36 exitWith $ ExitFailure 1
37 putStrLn "Build plan checked, no mismatches"
39 optionalCore = Set.fromList $ map packageVersionString $ Map.toList $ bpOptionalCore bp
40 notOptionalCore s = not $ s `Set.member` optionalCore
42getMismatches :: [String] -> [String] -> [Mismatch]
46 go [] y = map OnlySimpleList y
47 go x [] = map OnlyDryRun x
51 LT -> OnlyDryRun x : go xs (y:ys)
52 GT -> OnlySimpleList y : go (x:xs) ys
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list