examples/comment-on-diff.js
// find stuff in a diff and return the line number
find stuff in a diff and return the line number
find stuff in a diff and return the line number
function findOnLine(find, patch, cb) {
    if (find.test(patch)) {
        var lineNum = 0
        patch.split('\n').forEach(function(line) {
            var range = /\@\@ \-\d+,\d+ \+(\d+),\d+ \@\@/g.exec(line)
            if (range) {
                lineNum = Number(range[1]) - 1
            } else if (line.substr(0, 1) !== '-') {
                lineNum++
            }
            if (find.test(line)) {
                return cb(null, lineNum)
            }
        })
    }
}
function findOnLine ( find , patch , cb ) { if ( find . test ( patch ) ) { var lineNum = 0 patch . split ( '\n' ) . forEach ( function ( line ) { var range = / \@\@ \-\d+,\d+ \+(\d+),\d+ \@\@ / g . exec ( line ) if ( range ) { lineNum = Number ( range [ 1 ] ) - 1 } else if ( line . substr ( 0 , 1 ) !== '-' ) { lineNum ++ } if ( find . test ( line ) ) { return cb ( null , lineNum ) } } ) } }
find stuff in a diff and return the line number
find stuff in a diff and return the line number