packages feed

diff-parse 0.1.2 → 0.2.0

raw patch · 4 files changed

+27/−4 lines, 4 filesnew-uploaderPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

- Text.Diff.Parse.Types: fileDeltaHunks :: FileDelta -> [Hunk]
+ Text.Diff.Parse.Types: Binary :: Content
+ Text.Diff.Parse.Types: Hunks :: [Hunk] -> Content
+ Text.Diff.Parse.Types: data Content
+ Text.Diff.Parse.Types: fileDeltaContent :: FileDelta -> Content
+ Text.Diff.Parse.Types: instance Eq Content
+ Text.Diff.Parse.Types: instance Show Content
- Text.Diff.Parse.Types: FileDelta :: FileStatus -> Text -> Text -> [Hunk] -> FileDelta
+ Text.Diff.Parse.Types: FileDelta :: FileStatus -> Text -> Text -> Content -> FileDelta

Files

+ changelog view
@@ -0,0 +1,6 @@+-*-change-log-*-++0.2.0 February 2015+	* Added support for binary diffs. Note this is a breaking change. Calls to fileDeltaHunks need to be replaced with calls to fileDeltaContent.++0.1.2 Initial release
diff-parse.cabal view
@@ -1,5 +1,5 @@ Name:                   diff-parse-Version:                0.1.2+Version:                0.2.0 Author:                 Gabe Mulley <gabe@edx.org> Maintainer:             Gabe Mulley <gabe@edx.org> Category:               Parsing@@ -9,6 +9,7 @@ Description:            Parse output produced by git diff. Cabal-Version:          >= 1.18 Build-Type:             Simple+Extra-Source-Files:     changelog  Library   Default-Language:     Haskell2010
src/Text/Diff/Parse/Internal.hs view
@@ -13,6 +13,7 @@ import Text.Diff.Parse.Types  import Control.Applicative ((<|>), (*>), (<*), (<$>), (<*>), many)+import Control.Monad (void) import Data.Char (isSpace) import Data.Text (Text) @@ -30,6 +31,7 @@     , endOfInput     , letter     , space+    , try     )  @@ -42,8 +44,8 @@ fileDelta :: Parser FileDelta fileDelta = do     (status, source, dest) <- fileDeltaHeader-    hunks  <- many hunk-    return $ FileDelta status source dest hunks+    content <- try binary <|> hunks+    return $ FileDelta status source dest content  fileDeltaHeader :: Parser (FileStatus, Text, Text) fileDeltaHeader = do@@ -65,10 +67,22 @@ path :: Parser Text path = option "" (letter >> string "/") *> takeTill (\c -> (isSpace c) || (isEndOfLine c)) +hunks :: Parser Content+hunks = Hunks <$> many hunk+ hunk :: Parser Hunk hunk = Hunk <$> ("@@ -" *> range)             <*> (" +" *> range <* " @@" <* takeLine)             <*> (many annotatedLine)++binary :: Parser Content+binary = do+    void $ string "Binary files "+        <* path <* string " and "+        <* path <* string " differ"+        <* endOfLine++    return $ Binary  range :: Parser Range range = Range <$> decimal <*> (option 1 ("," *> decimal))
src/Text/Diff/Parse/Types.hs view
@@ -20,13 +20,15 @@   , hunkLines       :: [Line] } deriving (Show, Eq) +data Content = Binary | Hunks [Hunk] deriving (Show, Eq)+ data FileStatus = Created | Deleted | Modified deriving (Show, Eq)  data FileDelta = FileDelta {     fileDeltaStatus     :: FileStatus   , fileDeltaSourceFile :: Text   , fileDeltaDestFile   :: Text-  , fileDeltaHunks      :: [Hunk]+  , fileDeltaContent    :: Content } deriving (Show, Eq)  type FileDeltas = [FileDelta]