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 fro #5210
  • Loading branch information
snoyberg committed Mar 9, 2020
1 parent 246e15b commit 2886069
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 12 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.3.1.0
- 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
3 changes: 2 additions & 1 deletion stack-ghc-84.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ 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.1.0@rev:0
- github: commercialhaskell/pantry
commit: 400ae05722f1c3f5b8d9de46008a1fe6db325179
- casa-client-0.0.1@rev:0
- casa-types-0.0.1@rev:0
- github: snoyberg/filelock
Expand Down
8 changes: 4 additions & 4 deletions stack.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ library
, network-uri
, open-browser
, optparse-applicative
, pantry >=0.3.1.0
, 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.3.1.0
, 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.3.1.0
, 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.3.1.0
, pantry >=0.4.0.0
, path
, path-io
, persistent
Expand Down
3 changes: 2 additions & 1 deletion stack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ extra-deps:
- http-download-0.2.0.0@rev:0
- github: snoyberg/filelock
commit: 97e83ecc133cd60a99df8e1fa5a3c2739ad007dc
- pantry-0.3.1.0@rev:0
- github: commercialhaskell/pantry
commit: 400ae05722f1c3f5b8d9de46008a1fe6db325179
- casa-client-0.0.1@rev:0
- casa-types-0.0.1@rev:0

Expand Down

0 comments on commit 2886069

Please sign in to comment.