implemented api for diff annotations

This commit is contained in:
Sebastian Sdorra
2019-02-27 11:56:50 +01:00
parent 3ac47b0977
commit 891e3587b3
8 changed files with 280 additions and 44 deletions

View File

@@ -0,0 +1,18 @@
// @flow
import type { BaseContext, File, Hunk } from "./DiffTypes";
export function getPath(file: File) {
if (file.type === "delete") {
return file.oldPath;
}
return file.newPath;
}
export function createHunkIdentifier(file: File, hunk: Hunk) {
const path = getPath(file);
return `${file.type}_${path}_${hunk.content}`;
}
export function createHunkIdentifierFromContext(ctx: BaseContext) {
return createHunkIdentifier(ctx.file, ctx.hunk);
}