Skip to content

Commit

Permalink
Refactor CmdInstall
Browse files Browse the repository at this point in the history
CmdInstall.installAction is ~300 lines long and full of nested scopes
and ad-hoc logic. This change hopes to make it more readable and
understandable.

- Lift withProject and withoutProject out of installAction and split
  their relative concerns. E.g. not parsing URIs is installAction's
  concern not withProject's (which would just return a constant []).
- Split an intermediate step into a separate function, resolveTargetSelectorsInProjectBaseContext.
- Reuse withGlobalConfig and specFromPkgId (renamed from pidPackageSpecifiers).
- Avoid trying withProject a second time in case no target is specified.
- Fix a bug introduced in 802a326 where
  establishProjectBaseContext is called in a non-project setting. Also
  simplify its original implementation by moving the change into
  withProject rather than calling establishProjectBaseContext a second
  time.
- Document the interaction between cabal v2-install and local configuration
  and add few comments.
  • Loading branch information
andreabedini committed Feb 16, 2024
1 parent bd5bafc commit 4d55140
Show file tree
Hide file tree
Showing 9 changed files with 253 additions and 217 deletions.
367 changes: 204 additions & 163 deletions cabal-install/src/Distribution/Client/CmdInstall.hs
7 changes: 6 additions & 1 deletion cabal-install/src/Distribution/Client/CmdSdist.hs
5 changes: 2 additions & 3 deletions cabal-install/src/Distribution/Client/CmdUpdate.hs
51 changes: 17 additions & 34 deletions cabal-install/src/Distribution/Client/ProjectConfig.hs
3 changes: 3 additions & 0 deletions cabal-install/src/Distribution/Client/ProjectOrchestration.hs
2 changes: 2 additions & 0 deletions cabal-install/src/Distribution/Client/ProjectPlanning.hs
6 changes: 5 additions & 1 deletion cabal-install/src/Distribution/Client/ScriptUtils.hs
14 changes: 12 additions & 2 deletions cabal-install/src/Distribution/Client/Types/PackageSpecifier.hs

0 comments on commit 4d55140

Please sign in to comment.