UNPKG

1.33 kBTypeScriptView Raw
1import { Repository } from './repository';
2import { BlameOptions } from './blame-options';
3import { BlameHunk } from './blame-hunk';
4
5export namespace Blame {
6 const enum FLAG {
7 NORMAL = 0,
8 TRACK_COPIES_SAME_FILE = 1,
9 TRACK_COPIES_SAME_COMMIT_MOVES = 2,
10 TRACK_COPIES_SAME_COMMIT_COPIES = 4,
11 TRACK_COPIES_ANY_COMMIT_COPIES = 8,
12 FIRST_PARENT = 16,
13 }
14}
15
16export class Blame {
17 /**
18 * Retrieve the blame of a file
19 *
20 * @param repo - Repository that contains the file
21 * @param path - to the file to get the blame of
22 * @param [options] - Options for the blame
23 */
24 static file(repo: Repository, path: string, options?: BlameOptions): Promise<Blame>;
25 /**
26 * @param opts - The git_blame_options struct to initialize
27 * @param version - Version of struct; pass GIT_BLAME_OPTIONS_VERSION
28 */
29 static initOptions(opts: BlameOptions, version: number): number;
30
31 buffer(buffer: string, bufferLen: number): Promise<Blame>;
32
33 free(): void;
34 /**
35 * @returns - the hunk at the given index, or NULL on error
36 */
37 getHunkByIndex(index: number): BlameHunk;
38 /**
39 * @returns - the hunk that contains the given line, or NULL on error
40 */
41 getHunkByLine(lineNo: number): BlameHunk;
42
43 getHunkCount(): number;
44}