Skip to content

Commit

Permalink
Prioritize fixity overrides and module re-exports from command line
Browse files Browse the repository at this point in the history
  • Loading branch information
mrkkrp committed Feb 1, 2024
1 parent e4bdf81 commit f6e604f
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 7 deletions.
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
8 changes: 6 additions & 2 deletions 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,13 +35,15 @@
'';
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
diff --color=always test-1-ugly-expected.hs test-1-no-extra-info.hs
echo test-1-with-fixity-info-manual.hs
diff --color=always test-1-with-fixity-info-expected.hs test-1-with-fixity-info-manual.hs
echo test-1-with-fixity-info-dotormolu.hs
Expand Down
10 changes: 10 additions & 0 deletions fixity-tests/test-0-ugly-expected.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
instance A.ToJSON UpdateTable where
toJSON a =
A.object $
"TableName"
.= updateTableName a
:> "ProvisionedThroughput"
.= updateProvisionedThroughput a
:> case updateGlobalSecondaryIndexUpdates a of
[] -> []
l -> ["GlobalSecondaryIndexUpdates" .= l]

0 comments on commit f6e604f

Please sign in to comment.