function parseInternal()

in ng-dev/commit-message/parse.ts [125:167]


function parseInternal(fullText: string | Buffer): CommitFromGitLog | Commit {
  // Ensure the fullText symbol is a `string`, even if a Buffer was provided.
  fullText = fullText.toString();
  /** The commit message text with the fixup and squash markers stripped out. */
  const strippedCommitMsg = fullText
    .replace(FIXUP_PREFIX_RE, '')
    .replace(SQUASH_PREFIX_RE, '')
    .replace(REVERT_PREFIX_RE, '');
  /** The initially parsed commit. */
  const commit = parse(strippedCommitMsg, parseOptions);
  /** A list of breaking change notes from the commit. */
  const breakingChanges: ParsedCommit.Note[] = [];
  /** A list of deprecation notes from the commit. */
  const deprecations: ParsedCommit.Note[] = [];

  // Extract the commit message notes by marked types into their respective lists.
  commit.notes.forEach((note: ParsedCommit.Note) => {
    if (note.title === NoteSections.BREAKING_CHANGE) {
      breakingChanges.push(note);
    } else if (note.title === NoteSections.DEPRECATED) {
      deprecations.push(note);
    }
  });

  return {
    fullText,
    breakingChanges,
    deprecations,
    body: commit.body || '',
    footer: commit.footer || '',
    header: commit.header || '',
    references: commit.references,
    scope: commit.scope || '',
    subject: commit.subject || '',
    type: commit.type || '',
    isFixup: FIXUP_PREFIX_RE.test(fullText),
    isSquash: SQUASH_PREFIX_RE.test(fullText),
    isRevert: REVERT_PREFIX_RE.test(fullText),
    author: commit.author || undefined,
    hash: commit.hash || undefined,
    shortHash: commit.shortHash || undefined,
  };
}