Files
SCM-Manager/scm-ui/ui-components/src/repos/diffs.ts

18 lines
447 B
TypeScript
Raw Normal View History

import { BaseContext, File, Hunk } from "./DiffTypes";
2019-02-27 11:56:50 +01:00
export function getPath(file: File) {
if (file.type === "delete") {
2019-02-27 11:56:50 +01:00
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);
}