Skip to content

Commit

Permalink
Merge pull request commercialhaskell#5624 from hasufell/hasufell/PR/e…
Browse files Browse the repository at this point in the history
…xtra-deps-cloning

Fix cloning per subdirectory wrt commercialhaskell#5411
  • Loading branch information
snoyberg authored Oct 6, 2021
2 parents 708b516 + 5b4a3d4 commit 69f55d4
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 14 deletions.
2 changes: 2 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Major changes:

Behavior changes:

* cloning git repositories isn't per sub-directory anymore, see [#5411](https://github.com/commercialhaskell/stack/issues/5411)

Other enhancements:

* `stack setup` supports installing GHC for macOS aarch64 (M1)
Expand Down
2 changes: 1 addition & 1 deletion package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ dependencies:
- network-uri
- open-browser
- optparse-applicative >= 0.14.3.0
- pantry >= 0.5.2
- pantry >= 0.5.3
- casa-client
- casa-types
- path
Expand Down
9 changes: 9 additions & 0 deletions src/Stack/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE LambdaCase #-}

-- | The general Stack configuration that starts everything off. This should
-- be smart to falback if there is no stack.yaml, instead relying on
Expand Down Expand Up @@ -652,6 +653,14 @@ fillProjectWanted stackYamlFP config project locCache snapCompiler snapPackages
pp <- mkProjectPackage YesPrintWarnings resolved (boptsHaddock bopts)
pure (cpName $ ppCommon pp, pp)

-- prefetch git repos to avoid cloning per subdirectory
-- see https://github.com/commercialhaskell/stack/issues/5411
let gitRepos = mapMaybe (\case
(RPLImmutable (RPLIRepo repo rpm)) -> Just (repo, rpm)
_ -> Nothing) (projectDependencies project)
logDebug ("Prefetching git repos: " <> display (T.pack (show gitRepos)))
fetchReposRaw gitRepos

(deps0, mcompleted) <- fmap unzip . forM (projectDependencies project) $ \rpl -> do
(pl, mCompleted) <- case rpl of
RPLImmutable rpli -> do
Expand Down
9 changes: 1 addition & 8 deletions src/Stack/Setup.hs
Original file line number Diff line number Diff line change
Expand Up @@ -836,15 +836,8 @@ buildGhcFromSource getSetupInfo' installed (CompilerRepository url) commitId fla
if compilerTool `elem` installed
then return (compilerTool,CompilerBuildStandard)
else do
let repo = Repo
{ repoCommit = commitId
, repoUrl = url
, repoType = RepoGit
, repoSubdir = mempty
}

-- clone the repository and execute the given commands
Pantry.withRepo repo $ do
Pantry.withRepo (Pantry.SimpleRepo url commitId RepoGit) $ do
-- withRepo is guaranteed to set workingDirL, so let's get it
mcwd <- traverse parseAbsDir =<< view workingDirL
let cwd = fromMaybe (error "Invalid working directory") mcwd
Expand Down
1 change: 1 addition & 0 deletions stack-ghc-88.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ extra-deps:
- casa-types-0.0.1@rev:0
- rio-0.1.21.0@rev:0
- rio-prettyprint-0.1.1.0@rev:0
- pantry-0.5.3@rev:0

drop-packages:
# See https://github.com/commercialhaskell/stack/pull/4712
Expand Down
2 changes: 1 addition & 1 deletion stack-nightly.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ ghc-options:
"$locals": -fhide-source-paths

extra-deps:
- pantry-0.5.2@rev:0
- pantry-0.5.3@rev:0
- rio-0.1.21.0@rev:0

drop-packages:
Expand Down
8 changes: 4 additions & 4 deletions stack.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ library
, network-uri
, open-browser
, optparse-applicative >=0.14.3.0
, pantry >=0.5.2
, pantry >=0.5.3
, path
, path-io
, persistent
Expand Down Expand Up @@ -395,7 +395,7 @@ executable stack
, network-uri
, open-browser
, optparse-applicative >=0.14.3.0
, pantry >=0.5.2
, pantry >=0.5.3
, path
, path-io
, persistent
Expand Down Expand Up @@ -517,7 +517,7 @@ executable stack-integration-test
, open-browser
, optparse-applicative >=0.14.3.0
, optparse-generic
, pantry >=0.5.2
, pantry >=0.5.3
, path
, path-io
, persistent
Expand Down Expand Up @@ -644,7 +644,7 @@ test-suite stack-test
, network-uri
, open-browser
, optparse-applicative >=0.14.3.0
, pantry >=0.5.2
, pantry >=0.5.3
, path
, path-io
, persistent
Expand Down
2 changes: 2 additions & 0 deletions stack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ packages:

extra-deps:
- rio-0.1.21.0@rev:0
- pantry-0.5.3@rev:0


docker:
enable: false
Expand Down

0 comments on commit 69f55d4

Please sign in to comment.