import { parseGitCommitShowOutput } from '../parsers/parseGitShowOutput'; import { getDiffForCommit } from './getDiffForCommit'; import { CommitDiff } from '../interfaces/CommitDiff'; /** * Constructs an object that wraps the `git show` output for a commit. */ export async function getDiffObjectForCommit(commitHash: string): Promise { const diff = await getDiffForCommit(commitHash); exitIfDiffEmpty(diff); const diffObject = parseGitCommitShowOutput(diff); return diffObject; } function exitIfDiffEmpty(diff: string) { if (diff == "") { throw new Error('Diff empty. Exiting.'); } }