Skip to content

clear-pr-merge-commit-message - Clear redundant co-authors#9340

Merged
fregante merged 15 commits intorefined-github:mainfrom
agriyakhetarpal:clear-redundant-coauthor-messages-by-pr-author
May 5, 2026
Merged

clear-pr-merge-commit-message - Clear redundant co-authors#9340
fregante merged 15 commits intorefined-github:mainfrom
agriyakhetarpal:clear-redundant-coauthor-messages-by-pr-author

Conversation

@agriyakhetarpal
Copy link
Copy Markdown
Contributor

@agriyakhetarpal agriyakhetarpal commented May 2, 2026

This PR is a follow-up to #9336 as discussed in #9336 (comment) with @fregante. The idea is that if a PR author creates a PR, the author's own "Co-authored-by" commit messages added to the commit description at squash-merge time are redundant and can be removed. This also applies to bots, such as Dependabot, Renovate, pre-commit-ci, github-actions, and so on. In this case, we can remove them, as they also use private/noreply email addresses.

I've slightly adjusted the logic for getConversationAuthor, because the previous version wasn't working for me. Suggestions are welcome, thanks!

Test URLs

I tested this in a PR on my profile repository at agriyakhetarpal/agriyakhetarpal#1.

Screenshot

Here is a video:

Screen.Recording.2026-05-04.at.17.54.26.mov

As it can be seen, Co-authored-by: 74401230+agriyakhetarpal@users.noreply.github.com was cleared and is absent. example (I added them as a co-author on commit five)'s co-author message is preserved. For users with accounts before July 18, 2017, their privacy emails are of a different kind and are preserved (commit seven). For the bot case, i.e., github-actions[bot], its co-author message is preserved as well. Lastly, commit sign-offs are treated as separate from co-authoring and are thus preserved, too.

Thank you :)

Comment thread source/helpers/clean-commit-message.test.ts
Copy link
Copy Markdown
Member

@fregante fregante left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! I just have some nits

Comment thread source/github-helpers/index.ts
Comment thread source/helpers/clean-commit-message.ts Outdated
Comment thread source/helpers/clean-commit-message.ts Outdated
@fregante fregante changed the title clear-pr-merge-commit-message - Clear redundant coauthor messages by PR authors at merge time clear-pr-merge-commit-message - Clear redundant co-authors May 4, 2026
@agriyakhetarpal agriyakhetarpal marked this pull request as draft May 4, 2026 11:22
@agriyakhetarpal agriyakhetarpal marked this pull request as ready for review May 4, 2026 12:31
@agriyakhetarpal agriyakhetarpal requested a review from fregante May 4, 2026 12:32
@agriyakhetarpal
Copy link
Copy Markdown
Contributor Author

I hope this aligns better with what you had in mind – thanks for the suggestions!

Copy link
Copy Markdown
Member

@fregante fregante left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤘

Comment thread source/github-helpers/index.ts Outdated
Co-Authored-By: Grigory <techuila.sunset@gmail.com>
@SunsetTechuila
Copy link
Copy Markdown
Member

I don't understand why we need the getFirstComment function when we can reliably select the PR/issue body and pass it to getCommentAuthor:

export function getConversationAuthor(): string | undefined {
	const body = $optional(['.react-issue-body', '.js-command-palette-pull-body']);
	return body ? getCommentAuthor(body) : undefined;
}

Co-Authored-By: Grigory <techuila.sunset@gmail.com>
Comment thread source/features/clear-pr-merge-commit-message.tsx Outdated
@fregante
Copy link
Copy Markdown
Member

fregante commented May 4, 2026

I don't understand why we need the getFirstComment function

There are probably other features that can (and should) use this function. Since getCommentAuthor specifically expects one comment, the question would be why would you not pass one comment?

Co-Authored-By: Grigory <techuila.sunset@gmail.com>
@SunsetTechuila
Copy link
Copy Markdown
Member

Let's at least rename getFirstComment to getConversationBody

@agriyakhetarpal
Copy link
Copy Markdown
Contributor Author

Agreed!

Co-Authored-By: Grigory <techuila.sunset@gmail.com>
@SunsetTechuila
Copy link
Copy Markdown
Member

This doesn't work with bots due to a bug in getCommentAuthor. It doesn't add [bot] to bot names because it looks for an anchor with a URL starting with https://github.com/apps/ when it should look for a URL starting with /apps/

@SunsetTechuila
Copy link
Copy Markdown
Member

image

webpack/webpack#20899

if (!name.endsWith('[bot]') && $closestOptional('[href^="https://github.com/apps/"]', avatar)) {
// Example: https://github.com/webpack/webpack/pull/15926#issuecomment-1170670173
return name + '[bot]';
}

@agriyakhetarpal
Copy link
Copy Markdown
Contributor Author

Thanks, good catch! I couldn't have caught it with my own PR. For my curiosity: what is changing in October 2026?

@SunsetTechuila
Copy link
Copy Markdown
Member

what is changing in October 2026?

Six months will pass. I don't know when those links became relative, so it's safest to assume it happened just now. For users on older GitHub Enterprise versions, they are still absolute. We support GHE versions that are no older than six months

@SunsetTechuila
Copy link
Copy Markdown
Member

SunsetTechuila commented May 4, 2026

After writing this, I realized that links to public GitHub apps should probably always be absolute on GHE

Comment thread source/github-helpers/index.ts
@fregante fregante merged commit 888412e into refined-github:main May 5, 2026
10 checks passed
@agriyakhetarpal agriyakhetarpal deleted the clear-redundant-coauthor-messages-by-pr-author branch May 5, 2026 08:36
@agriyakhetarpal
Copy link
Copy Markdown
Contributor Author

Thanks to you both for making my recent contributions a pleasurable experience! I appreciate it a lot!

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

Development

Successfully merging this pull request may close these issues.

3 participants