Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prioritize fixity overrides and module re-exports from command line #1095

Merged
merged 1 commit into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
1087](https://github.com/tweag/ormolu/issues/1087).
* Improve comment placement in if-then-else blocks. [Issue
998](https://github.com/tweag/ormolu/issues/998).
* Now command line options for fixity overrides and module re-exports
overwrite information from `.ormolu` files. [Issue
1030](https://github.com/tweag/ormolu/issues/1030).

## Ormolu 0.7.3.0

Expand Down
12 changes: 7 additions & 5 deletions app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -168,15 +168,17 @@ formatOne ConfigFileOpts {..} mode reqSourceType rawConfig mpath =
fromMaybe
ModuleSource
(reqSourceType <|> mdetectedSourceType)
let mfixityOverrides = fst <$> mdotOrmolu
mmoduleReexports = snd <$> mdotOrmolu
return $
refineConfig
sourceType
mcabalInfo
mfixityOverrides
mmoduleReexports
rawConfig
(Just (cfgFixityOverrides rawConfig))
(Just (cfgModuleReexports rawConfig))
( rawConfig
{ cfgFixityOverrides = maybe defaultFixityOverrides fst mdotOrmolu,
cfgModuleReexports = maybe defaultModuleReexports snd mdotOrmolu
}
)
handleDiff originalInput formattedInput fileRepr =
case diffText originalInput formattedInput fileRepr of
Nothing -> return ExitSuccess
Expand Down
6 changes: 5 additions & 1 deletion fixity-tests/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
ormolu --check-idempotence --mode inplace --no-cabal --no-dot-ormolu --fixity 'infixr 8 .=' --fixity 'infixr 5 :>' test-0-with-fixity-info-manual.hs
cp test-0-input.hs test-0-with-fixity-info-dotormolu.hs
ormolu --check-idempotence --mode inplace --no-cabal -p base test-0-with-fixity-info-dotormolu.hs
cp test-0-input.hs test-0-cli-overrides-dotormolu.hs
ormolu --check-idempotence --mode inplace --no-cabal -p base --fixity 'infixr 5 .=' test-0-cli-overrides-dotormolu.hs
cp test-1-input.hs test-1-no-extra-info.hs
ormolu --check-idempotence --mode inplace --no-cabal --no-dot-ormolu test-1-no-extra-info.hs
cp test-1-input.hs test-1-with-fixity-info-manual.hs
Expand All @@ -33,11 +35,13 @@
'';
checkPhase = ''
echo test-0-no-extra-info.hs
diff --color=always test-0-no-extra-info-expected.hs test-0-no-extra-info.hs
diff --color=always test-0-ugly-expected.hs test-0-no-extra-info.hs
echo test-0-with-fixity-info-manual.hs
diff --color=always test-0-with-fixity-info-expected.hs test-0-with-fixity-info-manual.hs
echo test-0-with-fixity-info-dotormolu.hs
diff --color=always test-0-with-fixity-info-expected.hs test-0-with-fixity-info-dotormolu.hs
echo test-0-cli-overrides-dotormolu.hs
diff --color=always test-0-ugly-expected.hs test-0-cli-overrides-dotormolu.hs
echo test-1-no-extra-info.hs
diff --color=always test-1-no-extra-info-expected.hs test-1-no-extra-info.hs
echo test-1-with-fixity-info-manual.hs
Expand Down
Loading