Skip to content

clear-pr-merge-commit-message - Only clear squash merge commit messages#9398

Draft
Copilot wants to merge 6 commits intomainfrom
copilot/fix-clear-pr-merge-commit-message
Draft

clear-pr-merge-commit-message - Only clear squash merge commit messages#9398
Copilot wants to merge 6 commits intomainfrom
copilot/fix-clear-pr-merge-commit-message

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 8, 2026

Restores clear-pr-merge-commit-message to its documented scope: only squash merges should have their extended description cleared. Non-squash merge/rebase flows now keep GitHub’s default message body, which preserves the PR title in merge commit history.

The implementation now keeps the existing feature flow and performs the squash-only check directly inside clear() by matching the current merge button text.

if (!/squash/i.test($(confirmMergeButton).textContent)) {
	return;
}

Test URLs

Screenshot

Copilot AI and others added 3 commits May 8, 2026 17:36
Copilot AI changed the title [WIP] Fix clear PR merge commit message behavior clear-pr-merge-commit-message - Only clear squash merge commit messages May 8, 2026
Copilot AI requested a review from fregante May 8, 2026 17:40
await expectToken();
observe('textarea[placeholder="Add an optional extended description…"]', clear, {signal});
observe(mergeMessageFieldSelector, clearIfSquashing, {signal});
observe(confirmMergeButton, async () => {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You don't need to change anything in the init. Just make changes in "clear"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated in 20568f0. init is back to the single textarea observer and the squash-only check now happens inside clear. Screenshot: https://github.com/user-attachments/assets/b801fbb4-c4ee-4801-a41a-dfb0f78a09a3

}

async function clearIfSquashing(messageField: HTMLTextAreaElement): Promise<void> {
const mergeButton = $optional(confirmMergeButton);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Never optional, the button must exist.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated in 20568f0. I removed the optional lookup and now use $(confirmMergeButton).textContent directly. Screenshot: https://github.com/user-attachments/assets/b801fbb4-c4ee-4801-a41a-dfb0f78a09a3


async function clearIfSquashing(messageField: HTMLTextAreaElement): Promise<void> {
const mergeButton = $optional(confirmMergeButton);
if (!mergeButton || !isSquashMergeButtonText(mergeButton.textContent ?? '')) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Don't use a helper. Just inline /squash/i.test($(blah blah selector).textContent)

Don't use || '', not needed in this repo

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated in 20568f0. The helper is gone and the check is now inlined as /squash/i.test($(confirmMergeButton).textContent). Screenshot: https://github.com/user-attachments/assets/b801fbb4-c4ee-4801-a41a-dfb0f78a09a3

Copilot AI requested a review from fregante May 8, 2026 18:03
@SunsetTechuila
Copy link
Copy Markdown
Member

const mergeButton = $optional(confirmMergeButton);
const textContent = mergeButton?.textContent?.trim();
if (
!textContent || ![
'Confirm squash and merge',
'Confirm auto-merge (squash)',
'Confirm bypass rules and merge (squash)',
].includes(textContent)
) {
return false;
}

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

clear-pr-merge-commit-message should not clear non-squashed merge commit messages

3 participants