Skip to content

Commit

Permalink
Merge pull request #6487 from commercialhaskell/re6466
Browse files Browse the repository at this point in the history
Re #6466 stack init prefers snapshot to resolver
  • Loading branch information
mpilgrem authored Feb 15, 2024
2 parents 160c00a + 465506f commit bd4f2c9
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 13 deletions.
2 changes: 2 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ Behavior changes:
came with versions of GHC before 8.4.
* `stack path --global-config`, `--programs`, and `--local-bin` no longer set
up Stack's environment.
* The `init` command initialises `stack.yaml` with a `snapshot` key rather than
a `resolver` key.

Other enhancements:

Expand Down
22 changes: 11 additions & 11 deletions src/Stack/Init.hs
Original file line number Diff line number Diff line change
Expand Up @@ -256,12 +256,12 @@ initProject currDir initOpts mresolver = do
missingPkgMsg
| Map.size ignored > 0 =
"Warning (added by new or init): Some packages were found to be \
\incompatible with the resolver and have been left commented out \
\incompatible with the snapshot and have been left commented out \
\in the packages section.\n"
| otherwise = ""
extraDepMsg
| Map.size extraDeps > 0 =
"Warning (added by new or init): Specified resolver could not \
"Warning (added by new or init): Specified snapshot could not \
\satisfy all dependencies. Some external packages have been added \
\as dependencies.\n"
| otherwise = ""
Expand Down Expand Up @@ -405,7 +405,7 @@ renderStackYaml p ignoredPackages dupPackages =
-- Per Section Help
comments =
[ ("user-message" , userMsgHelp)
, ("resolver" , resolverHelp)
, ("snapshot" , snapshotHelp)
, ("packages" , packageHelp)
, ("extra-deps" , extraDepsHelp)
, ("flags" , "# Override default flag values for local packages and extra-deps")
Expand All @@ -419,20 +419,20 @@ renderStackYaml p ignoredPackages dupPackages =
, "For advanced use and comprehensive documentation of the format, please see:"
, "https://docs.haskellstack.org/en/stable/yaml_configuration/"
]
resolverHelp = commentHelp
[ "Resolver to choose a 'specific' stackage snapshot or a compiler version."
snapshotHelp = commentHelp
[ "A 'specific' Stackage snapshot or a compiler version."
, "A snapshot resolver dictates the compiler version and the set of packages"
, "to be used for project dependencies. For example:"
, ""
, "resolver: lts-22.7"
, "resolver: nightly-2024-01-20"
, "resolver: ghc-9.6.4"
, "snapshot: lts-22.7"
, "snapshot: nightly-2024-01-20"
, "snapshot: ghc-9.6.4"
, ""
, "The location of a snapshot can be provided as a file or url. Stack assumes"
, "a snapshot provided as a file might change, whereas a url resource does not."
, ""
, "resolver: ./custom-snapshot.yaml"
, "resolver: https://example.com/snapshots/2023-01-01.yaml"
, "snapshot: ./custom-snapshot.yaml"
, "snapshot: https://example.com/snapshots/2023-01-01.yaml"
]
userMsgHelp = commentHelp
[ "A warning or info to be displayed to the user on config load." ]
Expand All @@ -448,7 +448,7 @@ renderStackYaml p ignoredPackages dupPackages =
, " - wai"
]
extraDepsHelp = commentHelp
[ "Dependency packages to be pulled from upstream that are not in the resolver."
[ "Dependency packages to be pulled from upstream that are not in the snapshot."
, "These entries can reference officially published versions as well as"
, "forks / in-progress versions pinned to a git hash. For example:"
, ""
Expand Down
2 changes: 1 addition & 1 deletion src/Stack/Types/Project.hs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ instance ToJSON Project where
| not (Map.null project.flagsByPkg)
]
, ["packages" .= project.packages]
, ["resolver" .= project.resolver]
, ["snapshot" .= project.resolver]
, maybe [] (\c -> ["curator" .= c]) project.curator
, [ "drop-packages" .= Set.map CabalString project.dropPackages
| not (Set.null project.dropPackages)
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/tests/nice-resolver-names/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ main = do
for_ ["lts-20.26", "lts-22.7"] $ \snapshot -> do
stack ["init", "--force", "--snapshot", snapshot]
str <- readFile "stack.yaml"
case mapMaybe (stripPrefix "resolver: ") $ lines str of
case mapMaybe (stripPrefix "snapshot: ") $ lines str of
[x] ->
if filter (/= '\r') x == snapshot
then pure ()
Expand Down

0 comments on commit bd4f2c9

Please sign in to comment.