1
1
mirror of https://github.com/github/semantic.git synced 2024-12-25 16:02:43 +03:00

Add a truncatePatch function

This commit is contained in:
joshvera 2016-04-01 15:35:09 -04:00
parent 7947bc1911
commit a18c2649d3
2 changed files with 12 additions and 1 deletions

View File

@ -22,6 +22,12 @@ printDiff parser arguments sources = case format arguments of
Patch -> diffFiles parser P.patch sources
JSON -> diffFiles parser J.json sources
truncatedDiff :: DiffArguments -> Both SourceBlob -> IO Text
truncatedDiff arguments sources = case format arguments of
Split -> return ""
Patch -> return $ P.truncatePatch arguments sources
JSON -> return "{}"
printDiff' :: Parser -> DiffArguments -> Both SourceBlob -> IO ()
printDiff' parser arguments sources = case format arguments of
Split -> put (output arguments) =<< diffFiles parser split sources

View File

@ -1,7 +1,8 @@
module Renderer.Patch (
patch,
hunks,
Hunk(..)
Hunk(..),
truncatePatch
) where
import Alignment
@ -22,6 +23,10 @@ import Data.Maybe
import Data.Monoid
import Data.Text (pack, Text)
-- | Render a timed out file as a truncated diff.
truncatePatch :: DiffArguments -> Both SourceBlob -> Text
truncatePatch arguments blobs = pack $ header blobs ++ "#timed_out\nTruncating diff: timeout reached.\n"
-- | Render a diff in the traditional patch format.
patch :: Renderer a Text
patch diff blobs = pack $ case getLast (foldMap (Last . Just) string) of