@@ -11,7 +11,7 @@ def get_github_prs(token: str, owner: str, repo: str, label: str = "", state: st
11
11
token (str): GitHub token.
12
12
owner (str): The owner of the repository.
13
13
repo (str): The name of the repository.
14
- label (str): The label name.
14
+ label (str): The label name. Filter is not applied when empty string.
15
15
state (str): State of PR, e.g. open, closed, all
16
16
17
17
Returns:
@@ -89,7 +89,7 @@ def get_prs(pull_request_items: list[dict], label: str = "", state: str = "all")
89
89
90
90
Args:
91
91
pull_request_items (list[dict]): List of PR items.
92
- label (str): The label name.
92
+ label (str): The label name. Filter is not applied when empty string.
93
93
state (str): State of PR, e.g. open, closed, all
94
94
95
95
Returns:
@@ -99,14 +99,36 @@ def get_prs(pull_request_items: list[dict], label: str = "", state: str = "all")
99
99
pr_list = []
100
100
count = 0
101
101
for pr in pull_request_items :
102
- if pr ["state" ] == state and [item for item in pr ["labels" ] if item ["name" ] == label ]:
102
+ if state in [ pr ["state" ], "all" ] and ( not label or [item for item in pr ["labels" ] if item ["name" ] == label ]) :
103
103
pr_list .append (pr )
104
104
count += 1
105
105
106
- print (f"Found { count } PRs with { label if label else 'no' } label and state as { state } " )
106
+ print (f"Found { count } PRs with { label if label else 'no filter on ' } label and state as { state } " )
107
107
108
108
return pr_list
109
109
110
+ def get_prs_assignees (pull_request_items : list [dict ], label : str = "" , state : str = "all" ) -> list [str ]:
111
+ """
112
+ Returns a list of pull request assignees after applying the label and state filters, excludes jjw24.
113
+
114
+ Args:
115
+ pull_request_items (list[dict]): List of PR items.
116
+ label (str): The label name. Filter is not applied when empty string.
117
+ state (str): State of PR, e.g. open, closed, all
118
+
119
+ Returns:
120
+ list: A list of strs, where each string is an assignee name. List is not distinct, so can contain
121
+ duplicate names.
122
+ Returns an empty list if none are found.
123
+ """
124
+ assignee_list = []
125
+ for pr in pull_request_items :
126
+ if state in [pr ["state" ], "all" ] and (not label or [item for item in pr ["labels" ] if item ["name" ] == label ]):
127
+ [assignee_list .append (assignee ["login" ]) for assignee in pr ["assignees" ] if assignee ["login" ] != "jjw24" ]
128
+
129
+ print (f"Found { len (assignee_list )} assignees with { label if label else 'no filter on' } label and state as { state } " )
130
+
131
+ return assignee_list
110
132
111
133
def get_pr_descriptions (pull_request_items : list [dict ]) -> str :
112
134
"""
@@ -208,6 +230,11 @@ def update_pull_request_description(token: str, owner: str, repo: str, pr_number
208
230
description_content += f"## Features\n { get_pr_descriptions (enhancement_prs )} " if enhancement_prs else ""
209
231
description_content += f"## Bug fixes\n { get_pr_descriptions (bug_fix_prs )} " if bug_fix_prs else ""
210
232
233
+ assignees = list (set (get_prs_assignees (pull_requests , "enhancement" , "closed" ) + get_prs_assignees (pull_requests , "bug" , "closed" )))
234
+ assignees .sort (key = str .lower )
235
+
236
+ description_content += f"### Authors:\n { ', ' .join (assignees )} "
237
+
211
238
update_pull_request_description (
212
239
github_token , repository_owner , repository_name , release_pr [0 ]["number" ], description_content
213
240
)
0 commit comments