packages feed

stackage-curator 0.7.1.1 → 0.7.2

raw patch · 4 files changed

+81/−2 lines, 4 files

Files

ChangeLog.md view
@@ -1,3 +1,7 @@+## 0.7.2++* Add `diff` command+ ## 0.7.1.1  * Fix bug with existing .haddock file collection
+ Stackage/DiffPlans.hs view
@@ -0,0 +1,64 @@+{-# LANGUAGE OverloadedStrings, NoImplicitPrelude #-}+module Stackage.DiffPlans+    ( diffPlans+    ) where++import Stackage.Prelude+import Data.Yaml (decodeFileEither)++data Change = Added | Deleted | MajorBump | MinorBump | Unchanged+    deriving (Show, Eq, Ord)++data AndOr a = Old a | New a | Both a a+    deriving Show+instance Semigroup (AndOr a) where+    Old x <> New y = Both x y+    New y <> Old x = Both x y+    Old x <> Old _ = Old x+    New x <> New _ = New x+    Both x y <> _ = Both x y++diffPlans :: FilePath -- ^ old YAML build plan file+          -> FilePath -- ^ new YAML build plan file+          -> IO ()+diffPlans oldFP newFP = do+    old <- fmap Old <$> parse oldFP+    new <- fmap New <$> parse newFP+    let combined = unionWith (<>) old new+        m :: Map Change (Map PackageName Text)+        m = unionsWith mappend $ map go $ mapToList combined++    forM_ (mapToList m) $ \(change, m') -> do+        print change+        forM_ (mapToList m') $ \(pkg, msg) -> do+            putStrLn $ concat+                [ display pkg+                , ": "+                , msg+                ]+        putStrLn ""+  where+    parse fp = decodeFileEither (fpToString fp)+           >>= either throwIO (return . toSimple)++    toSimple = fmap ppVersion . bpPackages++    go (name, Old x) = singletonMap Deleted $ singletonMap name $ display x+    go (name, New x) = singletonMap Added $ singletonMap name $ display x+    go (name, Both x y)+        | x == y = singletonMap Unchanged $ singletonMap name $ display x+        | otherwise = singletonMap+            (if isMajor x y then MajorBump else MinorBump)+            (singletonMap name (concat+                [ display x+                , " ==> "+                , display y+                ]))++isMajor :: Version -> Version -> Bool+isMajor (Version old _) (Version new _) =+    toPair old /= toPair new+  where+    toPair [] = (0, 0)+    toPair [i] = (i, 0)+    toPair (i:j:_) = (i, j)
app/stackage.hs view
@@ -10,6 +10,7 @@ import Filesystem.Path.CurrentOS (decodeString) import Paths_stackage_curator (version) import Stackage.CompleteBuild+import Stackage.DiffPlans import Stackage.Upload import Stackage.InstallBuild import Stackage.Stats@@ -82,6 +83,11 @@                   printStatsFlags                   "stats"                   "Print statistics on a build plan"+            , cmnd+                (uncurry diffPlans)+                diffPlansFlags+                "diff"+                "Show the high-level differences between two build plans"             ]      cmnd exec parse name desc =@@ -227,6 +233,10 @@                <> value ""                 ) ) ) -    printStatsFlags = fmap decodeString $ strArgument+    printStatsFlags = yamlArg++    diffPlansFlags = (,) <$> yamlArg <*> yamlArg++    yamlArg = fmap decodeString $ strArgument          $ metavar "YAML-FILE"         <> help "YAML file containing a build plan"
stackage-curator.cabal view
@@ -1,5 +1,5 @@ name:                stackage-curator-version:             0.7.1.1+version:             0.7.2 synopsis:            Tools for curating Stackage bundles description:         Please see <http://www.stackage.org/package/stackage-curator> for a description and documentation. homepage:            https://github.com/fpco/stackage@@ -22,6 +22,7 @@                        Stackage.PackageIndex                        Stackage.BuildPlan                        Stackage.CheckBuildPlan+                       Stackage.DiffPlans                        Stackage.UpdateBuildPlan                        Stackage.GhcPkg                        Stackage.GithubPings