Skip to content

Commit d96d575

Browse files
committed
Simplifying description scanning phase.
1 parent 9a8766a commit d96d575

File tree

1 file changed

+14
-17
lines changed

1 file changed

+14
-17
lines changed

.github/scripts/branch_pr_issue_closer.py

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -215,15 +215,6 @@ def _main_prog():
215215
#Extract (lower case) Pull Request message:
216216
pr_msg_lower = merged_pull.body.lower()
217217

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-
227218
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
228219
#Extract issue and PR numbers associated with found keywords in merged PR message
229220
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@@ -234,19 +225,25 @@ def _main_prog():
234225
#Create new "closed" PR list:
235226
close_pulls = []
236227

228+
#Create iterator of all keyword/id pairs:
229+
word_matches = keyword_pattern.finditer(pr_msg_lower, re.IGNORECASE)
230+
237231
#Go through all matches to pull out PR and issue numbers:
232+
found_ids = []
238233
for match in word_matches:
239-
240234
issue_dict = match.groupdict()
241235
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
242246

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)
250247

251248
#+++END REFERENCED PR LOOP+++
252249

0 commit comments

Comments
 (0)