patchutils

package module
v0.0.0-...-47bbd14 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 28, 2020 License: ISC Imports: 12 Imported by: 0

README

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>

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

View Source
var ErrContentMismatch = errors.New("content mismatch")

ErrContentMismatch indicates that compared content is not same.

View Source
var ErrEmptyDiffFile = errors.New("empty diff file")

ErrEmptyDiffFile indicates that provided file doesn't contain any information about changes.

Functions

func InterDiff

func InterDiff(oldDiff, newDiff io.Reader) (string, error)

InterDiff computes the diff of a source file patched with oldDiff and the same source file patched with newDiff. oldDiff and newDiff should be in unified format.

func MixedModeFile

func MixedModeFile(oldSource, newSource, oldDiff, newDiff io.Reader) (string, error)

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

func MixedModePath

func MixedModePath(oldSourcePath, newSourcePath string, oldDiff, newDiff io.Reader) (string, error)

MixedModePath recursively computes the diff of an oldSource patched with oldDiff and the newSource patched with newDiff, recursively if OldSource and NewSource are directories.

Types

This section is empty.

Directories

Path Synopsis
Package main provides a cli tool to compute the diff between source and diff files.
Package main provides a cli tool to compute the diff between source and diff files.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL