Handle diff containing deleted symlinks Previously, this regex didn't match diffs for deleted symlinks: https://github.com/waigani/diffparser/blob/master/diffparser.go#L165 This led to an error here: https://github.com/waigani/diffparser/blob/master/diffparser.go#L167 If the Regex finds no matches, the code tried to index into an array of length 0.
DiffParser is a Golang package which parse's a git diff.
go get http://github.com/waigani/diffparser
package main import ( "fmt" "github.com/waigani/diffparser" ) // error handling left out for brevity func main() { byt, _ := ioutil.ReadFile("example.diff") diff, _ := diffparser.Parse(string(byt)) // You now have a slice of files from the diff, file := diff.Files[0] // diff hunks in the file, hunk := file.Hunks[0] // new and old ranges in the hunk newRange := hunk.NewRange // and lines in the ranges. line := newRange.Lines[0] }
See diffparser_test.go for further examples.