import { CommitDiff } from "../interfaces/CommitDiff"; import { generateHumanReadableCommitDiffDocument } from "../parsers/extractDiffContent"; import { getCommitHashesFromGitLog } from "./getCommitHashesFromGitLog"; import { getDiffObjectForCommit } from "./getDiffObjectForCommit"; /** * Retrieves the human-readable text of new commits on the current branch. * @returns A string containing the human-readable diff documents of the new commits. */ async function getHumanReadableTextOfNewCommitsOnCurrentBranch() { const commitHashes = await getCommitHashesFromGitLog(); // Get an object that wraps the `git log --oneline` output for each commit const commitDiffs: CommitDiff[] = []; for (const commitHash of commitHashes) { const diff = await getDiffObjectForCommit(commitHash); commitDiffs.push(diff); } const humanReadableDiffDocuments: string[] = [] for (const diff of commitDiffs) { const diffContent = generateHumanReadableCommitDiffDocument(diff) humanReadableDiffDocuments.push(diffContent) } return humanReadableDiffDocuments.join('\n') } export { getHumanReadableTextOfNewCommitsOnCurrentBranch }