Git Product home page Git Product logo

go-patchutils's Introduction

go-patchutils GoDoc Go Report Card

Package patchutils provides tools to compute the diff between source and diff files.

Works with diff files in unified format.

Table of contents

Design

Interdiff mode

InterDiff computes the diff of a source file patched with oldDiff and the same source file patched with newDiff, without access to the source.

Example
oldDiff newDiff
@@ -1,10 +1,13 @@
 80 days around the world.
-We’ll find a pot of gold
+You’ll find a pot of gold
 just sitting where the rainbow’s ending.
 
+Top Cat! The most effectual Top Cat!
+Who’s intellectual close friends get to call,
+providing it’s with dignity.
+The indisputable leader of the gang.

 Time — we’ll fight against the time,
 and we’ll fly on the white wings of the wind.
 
-80 days around the world,
-no we won’t say a word before
 the ship is really back.
@@ -2,9 +2,13 @@
 We’ll find a pot of gold
 just sitting where the rainbow’s ending.
 
+There’s a voice that keeps on calling me.
+Who’s intellectual close friends get to call,
+providing it’s with dignity.
+The indisputable leader of the gang.

 Time — we’ll fight against the time,
 and we’ll fly on the white wings of the wind.
 
-80 days around the world,
 no we won’t say a word before
 the ship is really back.
result
@@ -1,8 +1,8 @@
 80 days around the world.
+We’ll find a pot of gold
-You’ll find a pot of gold
 just sitting where the rainbow’s ending.
 
-Top Cat! The most effectual Top Cat!
+There’s a voice that keeps on calling me.
 Who’s intellectual close friends get to call,
 providing it’s with dignity.
 The indisputable leader of the gang.
 
 Time — we’ll fight against the time,
 and we’ll fly on the white wings of the wind.
 
+no we won’t say a word before
 the ship is really back.

Mixed mode

MixedMode computes the diff of an oldSource patched with oldDiff and newSource patched with newDiff.

Example
oldSource newSource
80 days around the world.
You’ll find a pot of gold
just sitting where the rainbow’s ending.

Top Cat! The most effectual Top Cat!
Who’s intellectual close friends get to call,
providing it’s with dignity.
The indisputable leader of the gang.

Time — we’ll fight against the time,
and we’ll fly on the white wings of the wind.

the ship is really back.
80 days around the world.
We’ll find a pot of gold
just sitting where the rainbow’s ending.

There’s a voice that keeps on calling me.
Who’s intellectual close friends get to call,
providing it’s with dignity.
The indisputable leader of the gang.

Time — we’ll fight against the time,
and we’ll fly on the white wings of the wind.

no we won’t say a word before
the ship is really back.
oldDiff newDiff
@@ -4,6 +4,7 @@
 
 Top Cat! The most effectual Top Cat!
 Who’s intellectual close friends get to call,
+Round, round, all around the world.
 providing it’s with dignity.
 The indisputable leader of the gang.
@@ -5,7 +5,6 @@
 There’s a voice that keeps on calling me.
 Who’s intellectual close friends get to call,
 providing it’s with dignity.
-The indisputable leader of the gang.
 
 Time — we’ll fight against the time,
 and we’ll fly on the white wings of the wind.
oldSource + oldDiff newSource + newDiff
80 days around the world.
You’ll find a pot of gold
just sitting where the rainbow’s ending.

Top Cat! The most effectual Top Cat!
Who’s intellectual close friends get to call,
Round, round, all around the world.
providing it’s with dignity.
The indisputable leader of the gang.

Time — we’ll fight against the time,
and we’ll fly on the white wings of the wind.

the ship is really back.
80 days around the world.
We’ll find a pot of gold
just sitting where the rainbow’s ending.

There’s a voice that keeps on calling me.
Who’s intellectual close friends get to call,
providing it’s with dignity.

Time — we’ll fight against the time,
and we’ll fly on the white wings of the wind.

no we won’t say a word before
the ship is really back.
result
@@ -1,14 +1,13 @@
 80 days around the world.
-You’ll find a pot of gold
+We’ll find a pot of gold
 just sitting where the rainbow’s ending.
 
-Top Cat! The most effectual Top Cat!
+There’s a voice that keeps on calling me.
 Who’s intellectual close friends get to call,
-Round, round, all around the world.
 providing it’s with dignity.
-The indisputable leader of the gang.
 
 Time — we’ll fight against the time,
 and we’ll fly on the white wings of the wind.
 
+no we won’t say a word before
 the ship is really back.

Installation

go get -u github.com/google/go-patchutils

Usage

API

Godoc is available.

CLI tool

Build CLI tool

cd cli
go build

Interdiff mode

./cli interdiff -olddiff=<path_to_old_diff> -newdiff=<path_to_new_diff>

Mixed mode

./cli mixed -oldsource=<path_to_old_source> -olddiff=<path_to_old_diff> 
-newsource=<path_to_new_source> -newdiff=<path_to_new_diff>

go-patchutils's People

Contributors

sofiia-tesliuk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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.