1
1
mirror of https://github.com/github/semantic.git synced 2024-11-25 02:58:36 +03:00

add-nonewline-diff-test

This commit is contained in:
joshvera 2016-03-11 17:02:50 -05:00
parent c6cd77803e
commit 14094590a8
2 changed files with 5 additions and 2 deletions

View File

@ -30,5 +30,5 @@ printDiff parser arguments sources = case format arguments of
then path </> (takeFileName outputPath -<.> ".html")
else path
IO.withFile outputPath IO.WriteMode (`TextIO.hPutStr` rendered)
Patch -> putStrLn =<< diffFiles parser P.patch sources
Patch -> putStr =<< diffFiles parser P.patch sources
JSON -> B.putStr =<< diffFiles parser J.json sources

View File

@ -46,8 +46,11 @@ rowIncrement = fmap lineIncrement
-- | Given the before and after sources, render a hunk to a string.
showHunk :: Both SourceBlob -> Hunk (SplitDiff a Info) -> String
showHunk blobs hunk = header blobs hunk ++ concat (showChange sources <$> changes hunk) ++ showLines (snd sources) ' ' (snd <$> trailingContext hunk)
showHunk blobs hunk = if last sourceHunk /= '\n'
then sourceHunk ++ "\n\\ No newline at end of file\n"
else sourceHunk
where sources = source <$> blobs
sourceHunk = header blobs hunk ++ concat (showChange sources <$> changes hunk) ++ showLines (snd sources) ' ' (snd <$> trailingContext hunk)
-- | Given the before and after sources, render a change to a string.
showChange :: Both (Source Char) -> Change (SplitDiff a Info) -> String