Skip to content

fix(commit): preserve author metadata in parseConventionalCommits - #2892

Open
piotrek-sblok wants to merge 1 commit into
googleapis:mainfrom
piotrek-sblok:fix/preserve-commit-author-2761
Open

fix(commit): preserve author metadata in parseConventionalCommits#2892
piotrek-sblok wants to merge 1 commit into
googleapis:mainfrom
piotrek-sblok:fix/preserve-commit-author-2761

Conversation

@piotrek-sblok

@piotrek-sblok piotrek-sblok commented Aug 27, 2026

Copy link
Copy Markdown

Recreates #2874, which was closed unmerged ("closing for now to keep the PR list tidy") with the source branch deleted. Credit for the original fix goes to @anishesg; #2874 has since had people asking for the fix, and #2761 is still open, so I've re-opened it from a live branch and dealt with the test fallout.

The bug

parseConventionalCommits() in src/commit.ts drops the author field when transforming Commit objects into ConventionalCommit objects. Everything else on the include-commit-authors path is wired correctly — config parsing, the strategy passing includeCommitAuthors into changelog note generation, GitHub commit fetching populating Commit.author, and DefaultChangelogNotes appending author info when options.includeCommitAuthors && commit.author — but by the time notes are rendered, commit.author is undefined, so author attribution never appears in the changelog.

The fix

author: commit.author in the object literal in parseConventionalCommits(), alongside the other preserved fields (sha, message, files, pullRequest).

Tests

  • test/commits.ts: a regression test asserting name/email/username survive parseConventionalCommits(). The existing coverage tests DefaultChangelogNotes in isolation with handcrafted commits that already carry author, so nothing exercised this path — which is why the bug slipped through. I confirmed the new test fails on main (expected undefined not to be undefined) and passes with the fix.
  • test/manifest.ts: the processCommits plugin-hook sinon.assert.calledWith compares against full commit literals, so it needed author: undefined added to the two expected commits. This was not part of fix(commit): preserve author metadata in parseConventionalCommits #2874 and is why the full suite would have gone red without it.

Fixes #2761

`parseConventionalCommits()` in `src/commit.ts` dropped the `author`
field when transforming `Commit` objects into `ConventionalCommit`
objects, so author metadata was lost before changelog rendering even
when `include-commit-authors` was enabled and the GitHub API had
provided author data.

Adds `author: commit.author` alongside the other preserved fields
(`sha`, `message`, `files`, `pullRequest`) and a regression test that
covers the full path through `parseConventionalCommits()`, which the
existing `DefaultChangelogNotes` tests did not.

The `processCommits` plugin-hook assertion in `test/manifest.ts` is
updated for the new field.

Fixes googleapis#2761

This recreates googleapis#2874 by @anishesg, which was closed unmerged.
@piotrek-sblok
piotrek-sblok requested review from a team as code owners August 27, 2026 09:30
@product-auto-label product-auto-label Bot added the size: s Pull request size is small. label Aug 27, 2026
@google-cla

google-cla Bot commented Aug 27, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: s Pull request size is small.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

include-commit-authors has no effect because author metadata is dropped in parseConventionalCommits()

1 participant