Skip to content

fix: default lines value #34

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix: default line value
  • Loading branch information
yeonjuan committed Dec 2, 2024
commit b936fc7d814a7995507c9b4d78413e0a2973a066
6 changes: 6 additions & 0 deletions src/__fixtures__/unified
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
diff --git a/test.txt b/test.txt
index 27b30e2..62944e1 100644
--- a/test.txt
+++ b/test.txt
@@ -2,0 +3 @@ bbb
+ddd
34 changes: 34 additions & 0 deletions src/__tests__/__snapshots__/unified.test.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`unified parse \`unified 1`] = `
{
"files": [
{
"chunks": [
{
"changes": [
{
"content": "ddd",
"lineAfter": 3,
"type": "AddedLine",
},
],
"context": "bbb",
"fromFileRange": {
"lines": 0,
"start": 2,
},
"toFileRange": {
"lines": 1,
"start": 3,
},
"type": "Chunk",
},
],
"path": "test.txt",
"type": "ChangedFile",
},
],
"type": "GitDiff",
}
`;
10 changes: 10 additions & 0 deletions src/__tests__/unified.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { getFixture } from './test-utils';
import parseGitDiff from '../parse-git-diff';

describe('unified', () => {
const fixture = getFixture('unified');

it('parse `unified', () => {
expect(parseGitDiff(fixture)).toMatchSnapshot();
});
});
2 changes: 1 addition & 1 deletion src/parse-git-diff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ function getRange(start: string, lines?: string) {
const startNum = parseInt(start, 10);
return {
start: startNum,
lines: lines === undefined ? startNum : parseInt(lines, 10),
lines: lines === undefined ? 1 : parseInt(lines, 10),
};
}

Expand Down
Loading