@@ -21,14 +21,16 @@ function copyPrDescription(event) {
21
21
return ;
22
22
} ;
23
23
24
- const titleField = document . getElementById ( 'merge_title_field' ) ;
25
- if ( ! titleField ) {
24
+ // When using auto-merge, GitHub has two text fields with the same ID.
25
+ const titleFields = document . querySelectorAll ( '[id=merge_title_field]' ) ;
26
+ if ( ! titleFields . length ) {
26
27
warn ( 'failed to find merge commit title field' ) ;
27
28
return ;
28
29
} ;
29
30
30
- const messageField = document . getElementById ( 'merge_message_field' ) ;
31
- if ( ! messageField ) {
31
+ // When using auto-merge, GitHub has two text fields with the same ID.
32
+ const messageFields = document . querySelectorAll ( '[id=merge_message_field]' ) ;
33
+ if ( ! messageFields . length ) {
32
34
warn ( 'failed to find merge commit body field' ) ;
33
35
return ;
34
36
} ;
@@ -39,13 +41,13 @@ function copyPrDescription(event) {
39
41
let commitBody = prBodyEl . textContent . replace ( / ^ < ! - - .* ?- - > \n * / gs, '' ) ;
40
42
41
43
// Preserve and de-duplicate co-authors
42
- const coauthors = new Set ( messageField . value . match ( / C o - a u t h o r e d - b y : .* / g) ) ;
44
+ const coauthors = new Set ( messageFields [ 0 ] . value . match ( / C o - a u t h o r e d - b y : .* / g) ) ;
43
45
if ( coauthors . size > 0 ) {
44
46
commitBody += '\n\n' + [ ...coauthors ] . join ( '\n' ) ;
45
47
}
46
48
47
- titleField . value = commitTitle ;
48
- messageField . value = commitBody ;
49
+ titleFields . forEach ( f => f . value = commitTitle ) ;
50
+ messageFields . forEach ( f => f . value = commitBody ) ;
49
51
}
50
52
51
53
function addMergeListener ( event ) {
0 commit comments