fix(commit): preserve author metadata in parseConventionalCommits - #2892
Open
piotrek-sblok wants to merge 1 commit into
Open
fix(commit): preserve author metadata in parseConventionalCommits#2892piotrek-sblok wants to merge 1 commit into
piotrek-sblok wants to merge 1 commit into
Conversation
`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.
|
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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()insrc/commit.tsdrops theauthorfield when transformingCommitobjects intoConventionalCommitobjects. Everything else on theinclude-commit-authorspath is wired correctly — config parsing, the strategy passingincludeCommitAuthorsinto changelog note generation, GitHub commit fetching populatingCommit.author, andDefaultChangelogNotesappending author info whenoptions.includeCommitAuthors && commit.author— but by the time notes are rendered,commit.authorisundefined, so author attribution never appears in the changelog.The fix
author: commit.authorin the object literal inparseConventionalCommits(), alongside the other preserved fields (sha,message,files,pullRequest).Tests
test/commits.ts: a regression test assertingname/email/usernamesurviveparseConventionalCommits(). The existing coverage testsDefaultChangelogNotesin isolation with handcrafted commits that already carryauthor, so nothing exercised this path — which is why the bug slipped through. I confirmed the new test fails onmain(expected undefined not to be undefined) and passes with the fix.test/manifest.ts: theprocessCommitsplugin-hooksinon.assert.calledWithcompares against full commit literals, so it neededauthor: undefinedadded 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