View on GitHub
File Changes
                       RepoTool.Types
                       RepoTool.UpdateCabal
                       RepoTool.UpdateHash
+
                       RepoTool.UpdateStack

                      
  build-depends:       base                             >= 4.10             && < 5
                     , ansi-terminal
import           RepoTool (RepoDirectory (..), gitCloneRepo, gitRepoStatuses,
                    gitResetChanges, printRepoName, renderRepoHash,
                    updateAllRepoGitHashes, gitPullRebase, updateCabalFromStack,
-
                    updateRepoGitHash)
+
                    updateRepoGitHash, updateStackFromCabal)

                      
import           System.Directory (doesDirectoryExist)
import           System.Environment (getProgName)
  | CmdUpdateGitHashes
  | CmdUpdateGitRepo RepoDirectory
  | CmdUpdateGitRepos
+
  | CmdUpdateStackFromCabal

                      
-- -----------------------------------------------------------------------------

                      
       ( Opt.info (pure CmdUpdateGitRepos)
       $ Opt.progDesc "Update all repos ('git checkout master && git pull --rebase')."
       )
+
    <> Opt.command "update-stack-yaml"
+
       ( Opt.info (pure CmdUpdateStackFromCabal)
+
       $ Opt.progDesc "Update git hashes in stack.yaml file (in the current directory) from the cabal.project file."
+
       )
    )

                      
pUpdateGitHash :: Parser Command
    CmdUpdateGitHashes -> validateRepos >> updateAllRepoGitHashes repos
    CmdUpdateGitRepo repo -> validateRepos >> gitPullRebase repo
    CmdUpdateGitRepos -> updateGitRepos
-

                      
+
    CmdUpdateStackFromCabal -> updateStackFromCabal

                      
updateGitRepos :: IO ()
updateGitRepos = do
m
+1/-0
import RepoTool.Text as X
import RepoTool.Types as X
import RepoTool.UpdateCabal as X
+
import RepoTool.UpdateStack as X
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
module RepoTool.UpdateCabal
-
  ( updateCabalFromStack
+
  ( extractRepoInfo
+
  , updateCabalFromStack
  ) where

                      
import qualified Data.List as List
+
{-# LANGUAGE OverloadedStrings #-}
+
{-# LANGUAGE ScopedTypeVariables #-}
+
module RepoTool.UpdateStack
+
  ( updateStackFromCabal
+
  ) where
+

                      
+
import qualified Data.Text.IO as Text
+

                      
+
import           RepoTool.Text
+
import           RepoTool.UpdateHash
+
import           RepoTool.UpdateCabal
+

                      
+
-- | Read all git repository/hash pairs from the stack.yaml file and apply
+
-- them to the cabal.project file in the same directory.
+
updateStackFromCabal :: IO ()
+
updateStackFromCabal = do
+
  cabalParts <- splitIntoParts <$> Text.readFile "cabal.project"
+
  stackParts <- splitIntoParts <$> Text.readFile "stack.yaml"
+
  Text.writeFile "stack.yaml" $
+
    concatParts (updateUrlHashes (extractRepoInfo cabalParts) stackParts)