Skip to content

Commit

Permalink
Lock files skip packages without cabal files
Browse files Browse the repository at this point in the history
This ties off the work from #5210
  • Loading branch information
snoyberg committed Mar 10, 2020
1 parent 3d0d235 commit d44cae4
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 13 deletions.
1 change: 1 addition & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Behavior changes:

* We now recommend checking in generated cabal files for repos. When generating lock files for
extra-deps that only include `package.yaml` files, a deprecation warning will be generated.
Also, those packages will no longer be included in the generated lock files.
See [#5210](https://github.com/commercialhaskell/stack/issues/5210).

Other enhancements:
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
- pantry >= 0.2
- pantry >= 0.4.0.0
- casa-client
- casa-types
- path
Expand Down
13 changes: 11 additions & 2 deletions src/Stack/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -592,8 +592,17 @@ fillProjectWanted stackYamlFP config project locCache snapCompiler snapPackages
(deps0, mcompleted) <- fmap unzip . forM (projectDependencies project) $ \rpl -> do
(pl, mCompleted) <- case rpl of
RPLImmutable rpli -> do
compl <- maybe (completePackageLocation rpli) pure (Map.lookup rpli locCache)
pure (PLImmutable compl, Just (CompletedPLI rpli compl))
(compl, mcompl) <-
case Map.lookup rpli locCache of
Just compl -> pure (compl, Just compl)
Nothing -> do
cpl <- completePackageLocation rpli
if cplHasCabalFile cpl
then pure (cplComplete cpl, Just $ cplComplete cpl)
else do
warnMissingCabalFile rpli
pure (cplComplete cpl, Nothing)
pure (PLImmutable compl, CompletedPLI rpli <$> mcompl)
RPLMutable p ->
pure (PLMutable p, Nothing)
dp <- additionalDepPackage (shouldHaddockDeps bopts) pl
Expand Down
3 changes: 2 additions & 1 deletion src/Stack/Init.hs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ initProject currDir initOpts mresolver = do
Map.mapMaybe (flip Map.lookup gpdByDir . resolvedAbsolute) rbundle

deps <- for (Map.toList extraDeps) $ \(n, v) ->
PLImmutable <$> completePackageLocation (RPLIHackage (PackageIdentifierRevision n v CFILatest) Nothing)
PLImmutable . cplComplete <$>
completePackageLocation (RPLIHackage (PackageIdentifierRevision n v CFILatest) Nothing)

let p = Project
{ projectUserMsg = if userMsg == "" then Nothing else Just userMsg
Expand Down
4 changes: 2 additions & 2 deletions src/Stack/Unpack.hs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ unpackPackages mSnapshot dest input = do
let (errs1, (names, pirs1)) =
fmap partitionEithers $ partitionEithers $ map parse input
locs1 <- forM pirs1 $ \pir -> do
loc <- completePackageLocation $ RPLIHackage pir Nothing
loc <- fmap cplComplete $ completePackageLocation $ RPLIHackage pir Nothing
pure (loc, packageLocationIdent loc)
(errs2, locs2) <- partitionEithers <$> traverse toLoc names
case errs1 ++ errs2 of
Expand Down Expand Up @@ -97,7 +97,7 @@ unpackPackages mSnapshot dest input = do
Nothing ->
pure $ Left $ "Package does not appear in snapshot: " ++ packageNameString name
Just sp -> do
loc <- completePackageLocation (rspLocation sp)
loc <- cplComplete <$> completePackageLocation (rspLocation sp)
pure $ Right (loc, packageLocationIdent loc)

-- Possible future enhancement: parse names as name + version range
Expand Down
2 changes: 1 addition & 1 deletion stack-ghc-84.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ extra-deps:
- rio-prettyprint-0.1.0.0@rev:0
- hi-file-parser-0.1.0.0@rev:0
- http-download-0.2.0.0@rev:0
- pantry-0.3.0.0@rev:0
- pantry-0.4.0.0@rev:0
- casa-client-0.0.1@rev:0
- casa-types-0.0.1@rev:0
- github: snoyberg/filelock
Expand Down
10 changes: 5 additions & 5 deletions stack.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ cabal-version: 2.0
--
-- see: https://github.com/sol/hpack
--
-- hash: 8e24d116d573127dc291b5f529dd435b6a82081766b9ff827fc039510e98f6fa
-- hash: 8f30d342ffc378818c52e483f656a29f7f917f5331d7b397ae245a74ff47292c

name: stack
version: 2.2.0
Expand Down Expand Up @@ -266,7 +266,7 @@ library
, network-uri
, open-browser
, optparse-applicative
, pantry >=0.2
, pantry >=0.4.0.0
, path
, path-io
, persistent
Expand Down Expand Up @@ -386,7 +386,7 @@ executable stack
, network-uri
, open-browser
, optparse-applicative
, pantry >=0.2
, pantry >=0.4.0.0
, path
, path-io
, persistent
Expand Down Expand Up @@ -505,7 +505,7 @@ executable stack-integration-test
, open-browser
, optparse-applicative
, optparse-generic
, pantry >=0.2
, pantry >=0.4.0.0
, path
, path-io
, persistent
Expand Down Expand Up @@ -627,7 +627,7 @@ test-suite stack-test
, network-uri
, open-browser
, optparse-applicative
, pantry >=0.2
, pantry >=0.4.0.0
, path
, path-io
, persistent
Expand Down
2 changes: 1 addition & 1 deletion stack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ extra-deps:
- http-download-0.2.0.0@rev:0
- github: snoyberg/filelock
commit: 97e83ecc133cd60a99df8e1fa5a3c2739ad007dc
- pantry-0.3.0.0@rev:0
- pantry-0.4.0.0@rev:0
- casa-client-0.0.1@rev:0
- casa-types-0.0.1@rev:0

Expand Down

0 comments on commit d44cae4

Please sign in to comment.