Tip: Use diffparser for git DSL
- Dominant language
- Kotlin
- Stars
- 542
- Forks
- 48
- PR merge metrics
- No merged PRs in 30d
Description
I struggled with the raw diffs at first, even writing my own parsers, before I discovered a better way. I thought I'd share a good library that works perfectly with `danger-kotlin`: https://github.com/thombergs/diffparser
Usage example:
```
@file:Repository("https://jcenter.bintray.com")
@file:DependsOn("io.reflectoring.diffparser:diffparser:1.4")
danger(args) {
val diff = UnifiedDiffParser().parse(git.diff!!.byteInputStream())
}
```
From that object, it's trivial to get changed files, lines added, removed, the different chunks etc. It's a small library, so autocompletion should be all the docs you need, really.
Contributor guide
No contributing guide indexed for this repository
Research direction
No file, test, or documentation entry point is named. First clarify whether this tip should become documentation for the git DSL, then locate the relevant documentation area and confirm that the diffparser example and dependency details are accurate before considering the work done.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- git, kotlin
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100