| commit | 79c8f4e68fb47321b45ceb2eda5e4a36785fda76 | [log] [tgz] |
|---|---|---|
| author | Nathan Leiby <[email protected]> | Sat Aug 10 22:18:10 2019 |
| committer | GitHub <[email protected]> | Sat Aug 10 22:18:10 2019 |
| tree | 628c5bfbfe9428df9990079559b7727755fb3645 | |
| parent | 1f7065f429b5b53c5029e3a6c198aab00f6a32c4 [diff] | |
| parent | 3eca51bfda7f25aece1a181e7147d2d4f1c63ae9 [diff] |
Merge pull request #16 from nakabonne/public-diffRange Make diffRange public
DiffParser is a Golang package which parse's a git diff.
go get 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.