File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -524,8 +524,12 @@ async function transferMergeRequests() {
524524 i => i . title . trim ( ) === mr . title . trim ( )
525525 ) ;
526526 let githubIssue = githubIssues . find (
527- // allow for issues titled "Original Issue Name [merged]"
528- i => i . title . trim ( ) . includes ( mr . title . trim ( ) )
527+ // allow for issues titled "Original Issue Name - [merged|closed]"
528+ i => {
529+ // regex needs escaping in case merge request title contains special characters
530+ const regex = new RegExp ( escapeRegExp ( mr . title . trim ( ) ) + ' - \\[(merged|closed)\\]' ) ;
531+ return regex . test ( i . title . trim ( ) ) ;
532+ }
529533 ) ;
530534 if ( ! githubRequest && ! githubIssue ) {
531535 if ( settings . skipMergeRequestStates . includes ( mr . state ) ) {
@@ -679,3 +683,7 @@ function inform(msg: string) {
679683 console . log ( msg ) ;
680684 console . log ( '==================================' ) ;
681685}
686+
687+ function escapeRegExp ( string ) {
688+ return string . replace ( / [ . * + ? ^ $ { } ( ) | [ \] \\ ] / g, '\\$&' ) ; // $& means the whole matched string
689+ }
You can’t perform that action at this time.
0 commit comments