@@ -11,7 +11,7 @@ def get_github_prs(token: str, owner: str, repo: str, label: str = "", state: st
1111 token (str): GitHub token.
1212 owner (str): The owner of the repository.
1313 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.
1515 state (str): State of PR, e.g. open, closed, all
1616
1717 Returns:
@@ -89,7 +89,7 @@ def get_prs(pull_request_items: list[dict], label: str = "", state: str = "all")
8989
9090 Args:
9191 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.
9393 state (str): State of PR, e.g. open, closed, all
9494
9595 Returns:
@@ -99,14 +99,36 @@ def get_prs(pull_request_items: list[dict], label: str = "", state: str = "all")
9999 pr_list = []
100100 count = 0
101101 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 ]) :
103103 pr_list .append (pr )
104104 count += 1
105105
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 } " )
107107
108108 return pr_list
109109
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
110132
111133def get_pr_descriptions (pull_request_items : list [dict ]) -> str :
112134 """
@@ -208,6 +230,11 @@ def update_pull_request_description(token: str, owner: str, repo: str, pr_number
208230 description_content += f"## Features\n { get_pr_descriptions (enhancement_prs )} " if enhancement_prs else ""
209231 description_content += f"## Bug fixes\n { get_pr_descriptions (bug_fix_prs )} " if bug_fix_prs else ""
210232
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+
211238 update_pull_request_description (
212239 github_token , repository_owner , repository_name , release_pr [0 ]["number" ], description_content
213240 )
0 commit comments