blob: 1c35ff5507f55b14c0dd297792cdc76a095396d2 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
import select from 'select-dom';
import * as pageDetect from 'github-url-detection';
import features from '.';
import onPrMergePanelOpen from '../github-events/on-pr-merge-panel-open';
function init(): void {
const messageField = select<HTMLTextAreaElement>('#merge_message_field')!;
const deduplicatedAuthors = new Set();
// This method ensures that "Co-authored-by" capitalization doesn't affect deduplication
for (const [, author] of messageField.value.matchAll(/co-authored-by: ([^\n]+)/gi)) {
deduplicatedAuthors.add('Co-authored-by: ' + author);
}
messageField.value = [...deduplicatedAuthors].join('\n');
}
void features.add({
id: __filebasename,
description: 'Clears the PR merge commit message of clutter, leaving only deduplicated co-authors.',
screenshot: 'https://user-images.githubusercontent.com/1402241/79257078-62b6fc00-7e89-11ea-8798-c06f33baa94b.png'
}, {
include: [
pageDetect.isPRConversation
],
exclude: [
// Don't clear 1-commit PRs #3140
() => select.all('.TimelineItem.js-commit').length === 1
],
additionalListeners: [
onPrMergePanelOpen
],
onlyAdditionalListeners: true,
waitForDomReady: false,
init
});
|