From 00954267f74034df31e58fb1c22a544dcb7d6f92 Mon Sep 17 00:00:00 2001 From: Julien Chaumond Date: Mon, 21 Sep 2020 11:50:16 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=A4=96=20Merge=20PR=20#47226=20[nodegit]?= =?UTF-8?q?=20Fix=20Blame-related=20methods=20by=20@julien-c?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [nodegit] Fix Blame-related methods * Add basic test --- types/nodegit/blame-hunk.d.ts | 16 ++++++++-------- types/nodegit/blame.d.ts | 2 +- types/nodegit/index.d.ts | 1 + types/nodegit/nodegit-tests.ts | 5 +++++ 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/types/nodegit/blame-hunk.d.ts b/types/nodegit/blame-hunk.d.ts index 58ab8e7191..385c060341 100644 --- a/types/nodegit/blame-hunk.d.ts +++ b/types/nodegit/blame-hunk.d.ts @@ -2,12 +2,12 @@ import { Oid } from './oid'; import { Signature } from './signature'; export class BlameHunk { - linesInHunk: number; - finalCommitId: Oid; - finalStartLineNumber: number; - finalSignature: Signature; - origCommitId: Oid; - origPath: string; - origStartLineNumber: number; - origSignature: Signature; + linesInHunk(): number; + finalCommitId(): Oid; + finalStartLineNumber(): number; + finalSignature(): Signature; + origCommitId(): Oid; + origPath(): string; + origStartLineNumber(): number; + origSignature(): Signature; } diff --git a/types/nodegit/blame.d.ts b/types/nodegit/blame.d.ts index f88dda9477..fd1289f558 100644 --- a/types/nodegit/blame.d.ts +++ b/types/nodegit/blame.d.ts @@ -21,7 +21,7 @@ export class Blame { * @param path - to the file to get the blame of * @param [options] - Options for the blame */ - static file(repo: Repository, path: string, options?: BlameOptions): Blame; + static file(repo: Repository, path: string, options?: BlameOptions): Promise; /** * @param opts - The git_blame_options struct to initialize * @param version - Version of struct; pass GIT_BLAME_OPTIONS_VERSION diff --git a/types/nodegit/index.d.ts b/types/nodegit/index.d.ts index 04e241d000..ac621d64f9 100644 --- a/types/nodegit/index.d.ts +++ b/types/nodegit/index.d.ts @@ -5,6 +5,7 @@ // Pierre Vigier // Jibril Saffi // Benjamin Schuster-Boeckler +// Julien Chaumond // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped export { AnnotatedCommit } from './annotated-commit'; diff --git a/types/nodegit/nodegit-tests.ts b/types/nodegit/nodegit-tests.ts index 0d8c195c29..b4394bc0b7 100644 --- a/types/nodegit/nodegit-tests.ts +++ b/types/nodegit/nodegit-tests.ts @@ -58,6 +58,11 @@ result = Git.Attr.value('attr'); const blameOptions = new Git.BlameOptions(); +Git.Blame.file(repo, 'path').then(blame => { + const hunk = blame.getHunkByLine(0); + hunk.linesInHunk(); +}); + Git.Branch.lookup(repo, 'branch_name', Git.Branch.BRANCH.LOCAL).then(reference => { // Use reference });