commit | 5209429c94567daf6bb232e12e4b973a568fa86f | [log] [tgz] |
---|---|---|
author | Nathan Leiby <nathan.leiby@clever.com> | Tue Aug 27 05:46:00 2019 |
committer | Nathan Leiby <nathan.leiby@clever.com> | Tue Aug 27 05:46:00 2019 |
tree | 063d725ac04614dd291e2ae786401f21582e60a4 | |
parent | 79c8f4e68fb47321b45ceb2eda5e4a36785fda76 [diff] |
use stretcher/testify instead of juju/testing
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.