diff --git a/types/git-diff-parser/git-diff-parser-tests.ts b/types/git-diff-parser/git-diff-parser-tests.ts new file mode 100644 index 0000000000..d5b767b159 --- /dev/null +++ b/types/git-diff-parser/git-diff-parser-tests.ts @@ -0,0 +1,19 @@ +import parser = require("git-diff-parser"); + +const input = `commit cd4a4e2db47f9642cf322fe109b5bfb3f6eb23c7 (HEAD -> master, origin/master, origin/HEAD) +Author: John Doe +Date: Thu Apr 1 23:59:59 2020 -0100 + + Just a typical commit message + +diff --git a/types/pkg/index.d.ts b/types/pkg/index.d.ts +index 60bb057b92..5c25c419d1 100644 +--- a/types/pkg/index.d.ts ++++ b/types/pkg/index.d.ts +@@ -3,3 +3,3 @@ declare namespace A { + */ +- aaa ++ bbb + /**`; + +parser(input); // $ExpectType Result diff --git a/types/git-diff-parser/index.d.ts b/types/git-diff-parser/index.d.ts new file mode 100644 index 0000000000..89da3e2ae0 --- /dev/null +++ b/types/git-diff-parser/index.d.ts @@ -0,0 +1,67 @@ +// Type definitions for git-diff-parser 1.0 +// Project: https://github.com/spookd/git-diff-parser +// Definitions by: Alexey Yaroshevich +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare function GitDiffParser(input: string | Buffer): GitDiffParser.Result; +declare namespace GitDiffParser { + /** Represents prefix in `git diff` output: '+', '-', or space */ + type LineType = 'deleted' | 'added' | 'normal'; + + interface Line { + type: LineType; + + /** Has line break. Always false for added failes */ + break: boolean; + + /** Content of removed or added string */ + text: string; + + /** The main line number */ + ln1: number; + + /** New line number (for type normal) */ + ln2?: number; + } + + interface File { + deleted: boolean; + added: boolean; + renamed: boolean; + binary: boolean; + lines: Line[]; + index?: string[]; + oldName?: string; + name: string; + } + + interface Commit { + files: File[]; + } + + interface DetailedCommit extends Commit { + message?: string; + sha?: string; + date?: Date; + author?: string; + email?: string; + } + + interface Result { + detailed: boolean; + commits: Commit[]; + } + + interface DryResult extends Result { + detailed: false; + } + + interface DetailedResult extends Result { + detailed: true; + commits: DetailedCommit[]; + } +} + +export = GitDiffParser; diff --git a/types/git-diff-parser/tsconfig.json b/types/git-diff-parser/tsconfig.json new file mode 100644 index 0000000000..a00902fbca --- /dev/null +++ b/types/git-diff-parser/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "git-diff-parser-tests.ts" + ] +} diff --git a/types/git-diff-parser/tslint.json b/types/git-diff-parser/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/git-diff-parser/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }