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:
parent
c6cd77803e
commit
14094590a8
@ -30,5 +30,5 @@ printDiff parser arguments sources = case format arguments of
|
|||||||
then path </> (takeFileName outputPath -<.> ".html")
|
then path </> (takeFileName outputPath -<.> ".html")
|
||||||
else path
|
else path
|
||||||
IO.withFile outputPath IO.WriteMode (`TextIO.hPutStr` rendered)
|
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
|
JSON -> B.putStr =<< diffFiles parser J.json sources
|
||||||
|
@ -46,8 +46,11 @@ rowIncrement = fmap lineIncrement
|
|||||||
|
|
||||||
-- | Given the before and after sources, render a hunk to a string.
|
-- | Given the before and after sources, render a hunk to a string.
|
||||||
showHunk :: Both SourceBlob -> Hunk (SplitDiff a Info) -> 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
|
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.
|
-- | Given the before and after sources, render a change to a string.
|
||||||
showChange :: Both (Source Char) -> Change (SplitDiff a Info) -> String
|
showChange :: Both (Source Char) -> Change (SplitDiff a Info) -> String
|
||||||
|
Loading…
Reference in New Issue
Block a user