https://github.com/gomodules/diffparser
GOlang library for parsing git diffs
https://github.com/gomodules/diffparser
Last synced: 6 months ago
JSON representation
GOlang library for parsing git diffs
- Host: GitHub
- URL: https://github.com/gomodules/diffparser
- Owner: gomodules
- License: mit
- Created: 2016-11-07T14:38:49.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-01-04T12:40:39.000Z (over 9 years ago)
- Last Synced: 2025-01-23T07:13:57.479Z (over 1 year ago)
- Language: Go
- Size: 13.7 KB
- Stars: 2
- Watchers: 10
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
[](https://cla-assistant.io/appscode/diffparser)
[Website](https://appscode.com) • [Slack](https://slack.appscode.com) • [Forum](https://discuss.appscode.com) • [Twitter](https://twitter.com/AppsCodeHQ)
DiffParser
===========
DiffParser is a Golang package for parsing git diffs. This supports diffs containing binary files. This library is forked from http://github.com/waigani/diffparser
Install
-------
```sh
go get http://github.com/appscode/diffparser
```
Usage Example
-------------
```go
package main
import (
"fmt"
"github.com/appscode/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]
}
```
More Examples
-------------
See diffparser_test.go for further examples.
Credits
-------
This repository started as a fork of https://github.com/waigani/diffparser .