Code Monkey home page Code Monkey logo

githubdiffparser's Introduction

githubdiffparser

Download

Parse GitHub diffs with Java. Modified fork of diffparser v1.2. Version numbers are now maintained independently.

Getting Started

  1. Specify githubdiffparser as a dependency in your build.gradle file:

    repositories {
        jcenter()
    }
    
    dependencies {
        compile 'com.github.stkent:githubdiffparser:1.0.1'
    }
  2. Parse GitHub diffs!

    GitHubDiffParser parser = new GitHubDiffParser();
    InputStream in = new FileInputStream("/path/to/file.diff");
    List<Diff> diff = parser.parse(in);
    

GitHub diff format

// TODO: give an example; explain how GitHub diffs appear to deviate from the unified diff spec.

The most detailed description of the unified diff format may be found here:

The unified output format starts with a two-line header, which looks like this:

--- from-file from-file-modification-time
+++ to-file to-file-modification-time

The time stamp looks like 2002-02-21 23:30:39.942229878 -0800 to indicate the date, time with fractional seconds, and time zone. The fractional seconds are omitted on hosts that do not support fractional time stamps.

You can change the header's content with the --label=label option. See Alternate Names.

Next come one or more hunks of differences; each hunk shows one area where the files differ. Unified format hunks look like this:

@@ from-file-line-numbers to-file-line-numbers @@
 line-from-either-file
 line-from-either-file...

If a hunk contains just one line, only its start line number appears. Otherwise its line numbers look like ‘start,count’. An empty hunk is considered to start at the line that follows the hunk.

If a hunk and its context contain two or more lines, its line numbers look like ‘start,count’. Otherwise only its end line number appears. An empty hunk is considered to end at the line that precedes the hunk.

The lines common to both files begin with a space character. The lines that actually differ between the two files have one of the following indicator characters in the left print column:

+: a line was added here to the first file.

-: a line was removed here from the first file.

githubdiffparser's People

Contributors

marcobeierer avatar ssoloff avatar stkent avatar thombergs avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.