bump 0.3.1
A fast and reliable git diff parser.
npm install gitdiff-parser
import gitDiffParser from 'gitdiff-parser'; gitDiffParser.parse(gitDiffText);
gitDiffText should be a diff output by git diff command.
gitDiffText
git diff
export interface Change { content: string; type: 'insert' | 'delete' | 'normal'; isInsert?: boolean; isDelete?: boolean; isNormal?: boolean; lineNumber?: number; oldLineNumber?: number; newLineNumber?: number; } export interface Hunk { content: string; oldStart: number; newStart: number; oldLines: number; newLines: number; changes: Change[]; } export interface File { hunks: Hunk[]; oldEndingNewLine: boolean; newEndingNewLine: boolean; oldMode: string; newMode: string; similarity?: number; oldRevision: string; newRevision: string; oldPath: string; newPath: string; isBinary?: boolean; type: 'add' | 'delete' | 'modify' | 'rename'; } export default { parse(source: string): File[]; };
版权所有:中国计算机学会技术支持:开源发展技术委员会 京ICP备13000930号-9 京公网安备 11010802032778号
gitdiff-parser
A fast and reliable git diff parser.
Install
Usage
gitDiffTextshould be a diff output bygit diffcommand.API