1
1
mirror of https://github.com/github/semantic.git synced 2024-12-23 14:54:16 +03:00

Define a command to render a diff.

This commit is contained in:
Rob Rix 2017-03-31 17:03:17 -04:00
parent 70b5505852
commit a0995343a3
2 changed files with 11 additions and 5 deletions

View File

@ -6,6 +6,7 @@ module Command
import Command.Diff as C
import Command.Parse as C
import Control.Monad.Free.Freer
import Data.Functor.Both
import Data.List ((\\))
import Data.RandomWalkSimilarity
import Data.Record
@ -22,6 +23,7 @@ import Git.Types
import GitmonClient
import Language
import Prologue
import Renderer
import Source
import Syntax
import Term
@ -34,8 +36,9 @@ data CommandF f where
Diff :: Term (Syntax Text) (Record DefaultFields) -> Term (Syntax Text) (Record DefaultFields) -> CommandF (Diff (Syntax Text) (Record DefaultFields))
RenderDiff :: DiffRenderer fields output -> SourceBlob -> SourceBlob -> Diff (Syntax Text) (Record fields) -> CommandF output
-- render a term
-- render a diff
-- parallelize diffs of a list of paths + git shas
-- explicit gitmon effects/events
@ -107,3 +110,6 @@ runCommand = iterFreerA $ \ command yield -> case command of
getLabel (h :< t) = (Info.category h, case t of
Leaf s -> Just s
_ -> Nothing)
RenderDiff renderer blob1 blob2 diff ->
yield (runDiffRenderer' renderer (both blob1 blob2) diff)

View File

@ -36,8 +36,8 @@ data DiffRenderer fields output where
SExpressionDiffRenderer :: (HasField fields Category, HasField fields SourceSpan) => SExpressionFormat -> DiffRenderer fields ByteString
ToCRenderer :: HasDefaultFields fields => DiffRenderer fields (Map Text (Map Text [Value]))
runDiffRenderer :: Both SourceBlob -> Diff (Syntax Text) (Record fields) -> DiffRenderer fields output -> Output
runDiffRenderer sources diff renderer = case renderer of
runDiffRenderer :: DiffRenderer fields output -> Both SourceBlob -> Diff (Syntax Text) (Record fields) -> Output
runDiffRenderer renderer sources diff = case renderer of
SplitRenderer -> SplitOutput (R.split sources diff)
PatchRenderer -> PatchOutput (R.patch sources diff)
JSONDiffRenderer -> JSONOutput (R.json sources diff)
@ -45,8 +45,8 @@ runDiffRenderer sources diff renderer = case renderer of
SExpressionDiffRenderer format -> SExpressionOutput (R.sExpression format sources diff)
ToCRenderer -> TOCOutput (R.toc sources diff)
runDiffRenderer' :: Both SourceBlob -> Diff (Syntax Text) (Record fields) -> DiffRenderer fields output -> output
runDiffRenderer' sources diff renderer = case renderer of
runDiffRenderer' :: DiffRenderer fields output -> Both SourceBlob -> Diff (Syntax Text) (Record fields) -> output
runDiffRenderer' renderer sources diff = case renderer of
SplitRenderer -> R.split sources diff
PatchRenderer -> R.patch sources diff
JSONDiffRenderer -> R.json sources diff