| commit | 92d851a4c63d614d6d10e419ca460232b891f486 | [log] [tgz] |
|---|---|---|
| author | waigani <[email protected]> | Tue Oct 20 02:39:26 2020 |
| committer | waigani <[email protected]> | Tue Oct 20 02:39:26 2020 |
| tree | 46145557be8d20d94f2affe976fd582cbb9625d0 | |
| parent | f0aed6936f8ce101b5ab3750b9bbef860e22dfd4 [diff] |
tweak
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.