Skip to content

Tip: Use diffparser for git DSL #304

Open
@hubertgrzeskowiak

Description

@hubertgrzeskowiak

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions