@@ -215,15 +215,6 @@ def _main_prog():
215
215
#Extract (lower case) Pull Request message:
216
216
pr_msg_lower = merged_pull .body .lower ()
217
217
218
- #End script if no keywords found:
219
- if keyword_pattern .search (pr_msg_lower ) is None :
220
- endmsg = f"Pull request #{ pr_num } was merged without using any of the keywords. "
221
- endmsg += "Thus there are no issues to close."
222
- end_script (endmsg )
223
-
224
- #search for at least one keyword in PR message:
225
- word_matches = keyword_pattern .finditer (pr_msg_lower , re .IGNORECASE )
226
-
227
218
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
228
219
#Extract issue and PR numbers associated with found keywords in merged PR message
229
220
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@@ -234,19 +225,25 @@ def _main_prog():
234
225
#Create new "closed" PR list:
235
226
close_pulls = []
236
227
228
+ #Create iterator of all keyword/id pairs:
229
+ word_matches = keyword_pattern .finditer (pr_msg_lower , re .IGNORECASE )
230
+
237
231
#Go through all matches to pull out PR and issue numbers:
232
+ found_ids = []
238
233
for match in word_matches :
239
-
240
234
issue_dict = match .groupdict ()
241
235
issue_num = int (issue_dict ['id' ].lstrip ('0' ))
236
+ found_ids .append (issue_num )
237
+
238
+ #End script if no keyword/id pairs were found:
239
+ if not found_ids :
240
+ endmsg = f"Pull request #{ pr_num } was merged without using any of the keywords. "
241
+ endmsg += "Thus there are no issues to close."
242
+ end_script (endmsg )
243
+
244
+ close_pulls = found_ids and open_pulls
245
+ close_issues = found_ids and open_issues
242
246
243
- #Check if number is actually for a PR (as opposed to an issue):
244
- if issue_num in open_pulls :
245
- #Add PR number to "close pulls" list:
246
- close_pulls .append (issue_num )
247
- elif issue_num in open_issues :
248
- #If in fact an issue, then add to "close issues" list:
249
- close_issues .append (issue_num )
250
247
251
248
#+++END REFERENCED PR LOOP+++
252
249
0 commit comments