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

Run the Diff command.

This commit is contained in:
Rob Rix 2017-03-31 15:45:33 -04:00
parent 8120a40c3e
commit 2d5afab020

View File

@ -6,11 +6,13 @@ module Command
import Command.Diff as C
import Command.Parse as C
import Control.Monad.Free.Freer
import Data.RandomWalkSimilarity
import Data.Record
import Data.String
import Debug.Trace (traceEventIO)
import Diff
import Info
import Interpreter
import qualified Git
import Git.Blob
import Git.Libgit2
@ -93,3 +95,11 @@ runCommand = iterFreerA $ \ command yield -> case command of
toSourceKind (Git.SymlinkBlob mode) = Source.SymlinkBlob mode
Parse language blob -> parserForLanguage language blob >>= yield
Diff term1 term2 ->
yield (stripDiff (diffTerms (decorate term1) (decorate term2)))
where decorate = defaultFeatureVectorDecorator getLabel
getLabel :: TermF (Syntax Text) (Record DefaultFields) a -> (Category, Maybe Text)
getLabel (h :< t) = (Info.category h, case t of
Leaf s -> Just s
_ -> Nothing)