mirror of
https://github.com/github/semantic.git
synced 2024-11-28 01:47:01 +03:00
Count the inserted & deleted lines.
This commit is contained in:
parent
6711d29ea4
commit
e22f951038
@ -8,7 +8,12 @@ patch diff sourceA sourceB = mconcat $ hunks diff sourceA sourceB
|
||||
data Hunk = Hunk Int Int [Line]
|
||||
|
||||
header :: Hunk -> String
|
||||
header (Hunk offsetA offsetB _) = "@@ -" ++ show offsetA ++ " +" ++ show offsetB ++ " @@\n"
|
||||
header (Hunk offsetA offsetB lines) = "@@ -" ++ show offsetA ++ " +" ++ show offsetB ++ " @@\n"
|
||||
where (countDeleted, countInserted) = foldl countLine (0, 0) lines
|
||||
countLine (countDeleted, countInserted) line = case line of
|
||||
Insert _ -> (countDeleted, countInserted + 1)
|
||||
Delete _ -> (countDeleted + 1, countInserted)
|
||||
Context _ -> (countDeleted + 1, countInserted + 1)
|
||||
|
||||
data Line = Insert String | Delete String | Context String
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user