Skip to content

Commit b936fc7

Browse files
committed
fix: default line value
1 parent 0b9dce8 commit b936fc7

File tree

4 files changed

+51
-1
lines changed

4 files changed

+51
-1
lines changed

src/__fixtures__/unified

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
diff --git a/test.txt b/test.txt
2+
index 27b30e2..62944e1 100644
3+
--- a/test.txt
4+
+++ b/test.txt
5+
@@ -2,0 +3 @@ bbb
6+
+ddd
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`unified parse \`unified 1`] = `
4+
{
5+
"files": [
6+
{
7+
"chunks": [
8+
{
9+
"changes": [
10+
{
11+
"content": "ddd",
12+
"lineAfter": 3,
13+
"type": "AddedLine",
14+
},
15+
],
16+
"context": "bbb",
17+
"fromFileRange": {
18+
"lines": 0,
19+
"start": 2,
20+
},
21+
"toFileRange": {
22+
"lines": 1,
23+
"start": 3,
24+
},
25+
"type": "Chunk",
26+
},
27+
],
28+
"path": "test.txt",
29+
"type": "ChangedFile",
30+
},
31+
],
32+
"type": "GitDiff",
33+
}
34+
`;

src/__tests__/unified.test.ts

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { getFixture } from './test-utils';
2+
import parseGitDiff from '../parse-git-diff';
3+
4+
describe('unified', () => {
5+
const fixture = getFixture('unified');
6+
7+
it('parse `unified', () => {
8+
expect(parseGitDiff(fixture)).toMatchSnapshot();
9+
});
10+
});

src/parse-git-diff.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ function getRange(start: string, lines?: string) {
280280
const startNum = parseInt(start, 10);
281281
return {
282282
start: startNum,
283-
lines: lines === undefined ? startNum : parseInt(lines, 10),
283+
lines: lines === undefined ? 1 : parseInt(lines, 10),
284284
};
285285
}
286286

0 commit comments

Comments
 (0)