Skip to content

Commit

Permalink
fix: Match better in parsing of git diff
Browse files Browse the repository at this point in the history
  • Loading branch information
relekang committed Apr 16, 2016
1 parent 006b5a9 commit 2e01e53
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/utils/git.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function parseDiffRanges(diff) {
return []
}

const filenameRegex = /a\/([^\n]+) b\/[^\n]+/
const filenameRegex = /^a\/([^\n]+) b\/[^\n]+/
export function parseDiffForFile(diff) {
const matches = filenameRegex.exec(diff)
if (matches === null) {
Expand All @@ -26,7 +26,7 @@ export function parseDiffForFile(diff) {
}

export function parseFullDiff(diff) {
return _(diff.split('diff --git '))
return _(`\n${diff}`.split('\ndiff --git '))
.map(parseDiffForFile)
.filter(_.isObject)
.reduce((lastValue, { filename, ranges }) => _.assign(
Expand Down

0 comments on commit 2e01e53

Please sign in to comment.