File size: 1,254 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# Unified Diff Viewer

This component renders the output of a unified diff (`git diff` or `diff -u`) in a
visual format recognizable by someone who works with `diff` and comparing files.

## Usage

```jsx
import DiffViewer from 'calypso/components/diff-viewer';

export const CommitView = ( { commitHash, description, diff } ) => (
	<div>
		<div>
			<a href="https://wordpress.com">{ commitHash }</a>
		</div>
		<p>{ description }</p>
		<DiffViewer diff={ diff } />
	</div>
);
```

### Props

| Name     | Type     | Default | Description                    |
| -------- | -------- | ------- | ------------------------------ |
| `diff`\* | `string` | `''`    | Actual text output of the diff |

### Additional usage information

The diff output should be the full text produced by the diff command (including newlines).
Internally this component relies on `jsdiff` to parse the output (the patch) and produce
the data structure used to display files, hunks (sections of change in the files), and
the actual lines of change and context.

```
diff --git a/circle.yml b/circle.yml
index 51455bdb14..bc0622d001 100644
--- a/circle.yml
+++ b/circle.yml
@@ -1,6 +1,6 @@
 machine:
   node:
-    version: 8.9.4
+    version: 8.11.0
 test:
   pre:
     - ? |
```