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 :: InstallInfo -> IO ()
21 (ec, dryRun', stderr) <- readProcessWithExitCode "cabal-dev" ("install":"--dry-run":"-fnetwork23":iiPackageList ii) ""
22 when (ec /= ExitSuccess || "Warning:" `isPrefixOf` stderr) $ do
25 putStrLn "cabal-dev returned a bad result, exiting"
27 let dryRun = sort $ filter notOptionalCore $ map (takeWhile (/= ' ')) $ drop 2 $ lines dryRun'
28 let mismatches = getMismatches dryRun (filter notOptionalCore $ iiPackageList ii)
29 unless (null mismatches) $ do
30 putStrLn "Found the following mismtaches"
31 mapM_ print mismatches
32 exitWith $ ExitFailure 1
34 optionalCore = Set.fromList $ map packageVersionString $ Map.toList $ iiOptionalCore ii
35 notOptionalCore s = not $ s `Set.member` optionalCore
37getMismatches :: [String] -> [String] -> [Mismatch]
41 go [] y = map OnlySimpleList y
42 go x [] = map OnlyDryRun x
46 LT -> OnlyDryRun x : go xs (y:ys)
47 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