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:
parent
7947bc1911
commit
a18c2649d3
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user