diffRgit: Create an HTML git diff widget using the diff2html library

Description Usage Arguments Note References Examples

Description

This function create an HTML widget to diplay a graphic view of a 'git diff' result.

Usage

1
2
3
4
diffRgit(diff, inputFormat = "diff", outputFormat = "side-by-side",
  showFiles = TRUE, matching = "none", synchronisedScroll = TRUE,
  matchWordsThreshold = 0.25, matchingMaxComparisons = 2500, width = NULL,
  height = NULL, elementId = NULL)

Arguments

diff

the result of a 'git diff'

inputFormat

the format of the input data: 'diff' or 'json', default is 'diff'

outputFormat

the format of the output data: 'line-by-line' or 'side-by-side', default is 'side-by-side'

showFiles

boolean to display or not the header with files changed, default is FALSE

matching

matching level: 'lines' for matching lines, 'words' for matching lines and words or 'none', default is 'none'

synchronisedScroll

scroll both panes in side-by-side mode: TRUE or FALSE, default is TRUE

matchWordsThreshold

similarity threshold for word matching, default is 0.25

matchingMaxComparisons

perform at most this much comparisons for line matching a block of changes, default is 2500

width

width of the widget

height

height of the widget

elementId

ID of the widget div

Note

All parameters are directly send to diff2html function to be compatible with futures versions.

References

See https://diff2html.xyz for more informations.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
library(diffRgit)

#get git diff with system('git diff file1 file2", intern = TRUE) instead
l_diff <- "diff --git a/../diff2widget/file1 b/../diff2widget/file2\nindex ab63d51..eb01961 100644\n--- a/../diff2widget/file1\n+++ b/../diff2widget/file2\n@ -1,5 +1,4 @\n-hello!\n+hello world!\n Where is Bryan?\n+Bryan is in the kitchen.\n bye!\n-\n-oups!"
diffRgit(l_diff)

#see diff line by line
diffRgit(l_diff, outputFormat = 'line-by-line')

#remove header
diffRgit(l_diff, showFiles = FALSE)

abossi/diffRgit documentation built on May 10, 2019, 4:14 a.m.