Skip to content

Commit

Permalink
fix: handle binary files and undefined path from gitdiff-parser (#69)
Browse files Browse the repository at this point in the history
  • Loading branch information
jpoehnelt authored Sep 14, 2020
1 parent 646fc4c commit 4d4740d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/annotate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,24 @@ test("should annotate correctly", () => {
]);
});

test("should annotate case without newPath", () => {
// sourced from https://patch-diff.githubusercontent.com/raw/bwvalle/learnopencv/pull/7.diff
const files = [
{
hunks: [],
newEndingNewLine: true,
newMode: "100644",
newRevision: "00c87967",
oldEndingNewLine: true,
oldRevision: "00000000",
type: "modify",
},
];

const annotations = annotate(DEFAULT_CONFIGURATION, files as any);
expect(annotations).toEqual([]);
});

test("should get correct level from annotations", () => {
expect(getLevelFromAnnotations([])).toBe(Level.OFF);
expect(
Expand Down
2 changes: 2 additions & 0 deletions src/annotate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ export const annotate = (
for (const f of files) {
if (
f.type === "delete" ||
f.isBinary ||
f.newPath === undefined ||
config.ignore.some((pattern) => minimatch(f.newPath, pattern))
) {
continue;
Expand Down

0 comments on commit 4d4740d

Please sign in to comment.