Skip to content

Commit

Permalink
Simplifying description scanning phase.
Browse files Browse the repository at this point in the history
  • Loading branch information
mwaxmonsky committed Aug 22, 2024
1 parent 9a8766a commit d96d575
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions .github/scripts/branch_pr_issue_closer.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,15 +215,6 @@ def _main_prog():
#Extract (lower case) Pull Request message:
pr_msg_lower = merged_pull.body.lower()

#End script if no keywords found:
if keyword_pattern.search(pr_msg_lower) is None:
endmsg = f"Pull request #{pr_num} was merged without using any of the keywords. "
endmsg += "Thus there are no issues to close."
end_script(endmsg)

#search for at least one keyword in PR message:
word_matches = keyword_pattern.finditer(pr_msg_lower, re.IGNORECASE)

#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#Extract issue and PR numbers associated with found keywords in merged PR message
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Expand All @@ -234,19 +225,25 @@ def _main_prog():
#Create new "closed" PR list:
close_pulls = []

#Create iterator of all keyword/id pairs:
word_matches = keyword_pattern.finditer(pr_msg_lower, re.IGNORECASE)

#Go through all matches to pull out PR and issue numbers:
found_ids = []
for match in word_matches:

issue_dict = match.groupdict()
issue_num = int(issue_dict['id'].lstrip('0'))
found_ids.append(issue_num)

#End script if no keyword/id pairs were found:
if not found_ids:
endmsg = f"Pull request #{pr_num} was merged without using any of the keywords. "
endmsg += "Thus there are no issues to close."
end_script(endmsg)

close_pulls = found_ids and open_pulls
close_issues = found_ids and open_issues

#Check if number is actually for a PR (as opposed to an issue):
if issue_num in open_pulls:
#Add PR number to "close pulls" list:
close_pulls.append(issue_num)
elif issue_num in open_issues:
#If in fact an issue, then add to "close issues" list:
close_issues.append(issue_num)

#+++END REFERENCED PR LOOP+++

Expand Down

0 comments on commit d96d575

Please sign in to comment.