Skip to content

Commit

Permalink
Fix parseLine
Browse files Browse the repository at this point in the history
  • Loading branch information
fujimura committed Jun 11, 2014
1 parent ccf5250 commit 3ed514c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Git/Freq.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type Result = Map FileName NumStat
parseLine :: Text -> Maybe Change
parseLine = go . T.splitOn (T.pack "\t")
where go :: [Text] -> Maybe Change
go (_:_:"":_) = Nothing
go (added:deleted:filename:_) =
case (readIntMaybe added, readIntMaybe deleted) of
(Just a, Just d) -> Just (filename, (a, d))
Expand Down
3 changes: 3 additions & 0 deletions test/Git/FreqSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ spec = do
source <- createMockSource [ "1\t1\tgit-freq.cabal"
, "2\t5\tREADME.md"
, "3\t0\tgit-freq.cabal"
, "%0"
, "4\t3\t"
, "4\t\t3\tfoo"
, "2\t9\tREADME.md"
]
freq' source `shouldReturn` [ ("README.md", (4, 14))
Expand Down

0 comments on commit 3ed514c

Please sign in to comment.