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

Don't write out the cabal file if it matches the old one #555

Closed
Closed
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
7 changes: 4 additions & 3 deletions src/Hpack.hs
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ hpackResultWithVersion v (Options options force generateHashStrategy toStdout) =
NoForce -> maybe Generated (mkStatus newCabalFile) mExistingCabalFile

case status of
Generated -> writeCabalFile options toStdout cabalFileName newCabalFile
Generated -> writeCabalFile options toStdout cabalFileName mExistingCabalFile newCabalFile
_ -> return ()

return $ Right Result {
Expand All @@ -258,8 +258,9 @@ hpackResultWithVersion v (Options options force generateHashStrategy toStdout) =
}
Left err -> return $ Left err

writeCabalFile :: DecodeOptions -> Bool -> FilePath -> CabalFile -> IO ()
writeCabalFile options toStdout name cabalFile = do
writeCabalFile :: DecodeOptions -> Bool -> FilePath -> Maybe CabalFile -> CabalFile -> IO ()
writeCabalFile _ _ _ (Just oldCabalFile) newCabalFile | oldCabalFile == newCabalFile = mempty
writeCabalFile options toStdout name _ cabalFile = do
write . unlines $ renderCabalFile (decodeOptionsTarget options) cabalFile
where
write = if toStdout then Utf8.putStr else Utf8.writeFile name
Expand Down