🤖 Merge PR #47226 [nodegit] Fix Blame-related methods by @julien-c

* [nodegit] Fix Blame-related methods

* Add basic test
This commit is contained in:
Julien Chaumond 2020-09-21 11:50:16 +02:00 committed by GitHub
parent 82f3ed91c5
commit 00954267f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 9 deletions

View File

@ -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;
}

View File

@ -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<Blame>;
/**
* @param opts - The git_blame_options struct to initialize
* @param version - Version of struct; pass GIT_BLAME_OPTIONS_VERSION

View File

@ -5,6 +5,7 @@
// Pierre Vigier <https://github.com/pvigier>
// Jibril Saffi <https://github.com/IGI-111>
// Benjamin Schuster-Boeckler <https://github.com/DaGaMs>
// Julien Chaumond <https://github.com/julien-c>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export { AnnotatedCommit } from './annotated-commit';

View File

@ -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
});