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)
16data Mismatch = OnlyDryRun String | OnlySimpleList String
19checkPlan :: BuildPlan -> IO ()
21 putStrLn "Checking build plan"
22 (ec, dryRun', stderr) <- readProcessWithExitCode "cabal" (addCabalArgsOnlyGlobal $ "install":"--dry-run":bpPackageList bp) ""
23 when (ec /= ExitSuccess || "Warning:" `isPrefixOf` stderr) $ do
26 putStrLn "cabal returned a bad result, exiting"
28 let dryRun = sort $ filter notOptionalCore $ map (takeWhile (/= ' ')) $ drop 2 $ lines dryRun'
29 let mismatches = getMismatches dryRun (filter notOptionalCore $ bpPackageList bp)
30 unless (null mismatches) $ do
31 putStrLn "Found the following mismatches"
32 mapM_ print mismatches
33 exitWith $ ExitFailure 1
34 putStrLn "Build plan checked, no mismatches"
36 optionalCore = Set.fromList $ map packageVersionString $ Map.toList $ bpOptionalCore bp
37 notOptionalCore s = not $ s `Set.member` optionalCore
39getMismatches :: [String] -> [String] -> [Mismatch]
43 go [] y = map OnlySimpleList y
44 go x [] = map OnlyDryRun x
48 LT -> OnlyDryRun x : go xs (y:ys)
49 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