From e700e4af631bfcec196c466f3c5a7455f9af59da Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Tue, 3 Jun 2025 12:09:28 +0000 Subject: [PATCH 1/4] add get authors on PRs to workflow --- .github/update_release_pr.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/.github/update_release_pr.py b/.github/update_release_pr.py index f90f6181d01..55c109b9bf7 100644 --- a/.github/update_release_pr.py +++ b/.github/update_release_pr.py @@ -107,6 +107,27 @@ def get_prs(pull_request_items: list[dict], label: str = "", state: str = "all") return pr_list +def get_prs_assignees(pull_request_items: list[dict], label: str = "", state: str = "all") -> list[str]: + """ + Returns a list of pull request assignees after applying the label and state filters, excludes jjw24. + + Args: + pull_request_items (list[dict]): List of PR items. + label (str): The label name. + state (str): State of PR, e.g. open, closed, all + + Returns: + list: A list of strs, where each string represents an assignee. + Returns an empty list if none are found. + """ + assignee_list = [] + for pr in pull_request_items: + if pr["state"] == state and [item for item in pr["labels"] if item["name"] == label]: + [assignee_list.append(assignee["login"]) for assignee in pr["assignees"] if assignee["login"] != "jjw24" ] + + print(f"Found {len(assignee_list)} assignees with {label if label else 'no'} label and state as {state}") + + return assignee_list def get_pr_descriptions(pull_request_items: list[dict]) -> str: """ @@ -208,6 +229,11 @@ def update_pull_request_description(token: str, owner: str, repo: str, pr_number description_content += f"## Features\n{get_pr_descriptions(enhancement_prs)}" if enhancement_prs else "" description_content += f"## Bug fixes\n{get_pr_descriptions(bug_fix_prs)}" if bug_fix_prs else "" + assignees = list(set(get_prs_assignees(pull_requests, "enhancement", "closed") + get_prs_assignees(pull_requests, "bug", "closed"))) + assignees.sort(key=str.lower) + + description_content += f"### Authors: {','.join(assignees)}" + update_pull_request_description( github_token, repository_owner, repository_name, release_pr[0]["number"], description_content ) From b1b3fba09c27d4ddc6ebd9f7ce019a6116c27ce4 Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Tue, 3 Jun 2025 12:14:21 +0000 Subject: [PATCH 2/4] formatting --- .github/update_release_pr.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/update_release_pr.py b/.github/update_release_pr.py index 55c109b9bf7..5779b4c7727 100644 --- a/.github/update_release_pr.py +++ b/.github/update_release_pr.py @@ -232,7 +232,7 @@ def update_pull_request_description(token: str, owner: str, repo: str, pr_number assignees = list(set(get_prs_assignees(pull_requests, "enhancement", "closed") + get_prs_assignees(pull_requests, "bug", "closed"))) assignees.sort(key=str.lower) - description_content += f"### Authors: {','.join(assignees)}" + description_content += f"### Authors:\n{', '.join(assignees)}" update_pull_request_description( github_token, repository_owner, repository_name, release_pr[0]["number"], description_content From 725b3404e553f8fe7f10679157f5fdcd96f392b8 Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Thu, 5 Jun 2025 10:58:53 +0000 Subject: [PATCH 3/4] allow use of no label on assignee search --- .github/update_release_pr.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/update_release_pr.py b/.github/update_release_pr.py index 5779b4c7727..e67424264b3 100644 --- a/.github/update_release_pr.py +++ b/.github/update_release_pr.py @@ -117,12 +117,13 @@ def get_prs_assignees(pull_request_items: list[dict], label: str = "", state: st state (str): State of PR, e.g. open, closed, all Returns: - list: A list of strs, where each string represents an assignee. + list: A list of strs, where each string is an assignee name. List is not distinct, so can contain + duplicate names. Returns an empty list if none are found. """ assignee_list = [] for pr in pull_request_items: - if pr["state"] == state and [item for item in pr["labels"] if item["name"] == label]: + if pr["state"] == state and [item for item in pr["labels"] if not label or item["name"] == label]: [assignee_list.append(assignee["login"]) for assignee in pr["assignees"] if assignee["login"] != "jjw24" ] print(f"Found {len(assignee_list)} assignees with {label if label else 'no'} label and state as {state}") From 24742fc3a951f8bf1fd5a08e20d0f83668752fb3 Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Thu, 5 Jun 2025 12:24:04 +0000 Subject: [PATCH 4/4] fix filtering for state all and no label --- .github/update_release_pr.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/update_release_pr.py b/.github/update_release_pr.py index e67424264b3..ccea511b31f 100644 --- a/.github/update_release_pr.py +++ b/.github/update_release_pr.py @@ -11,7 +11,7 @@ def get_github_prs(token: str, owner: str, repo: str, label: str = "", state: st token (str): GitHub token. owner (str): The owner of the repository. repo (str): The name of the repository. - label (str): The label name. + label (str): The label name. Filter is not applied when empty string. state (str): State of PR, e.g. open, closed, all Returns: @@ -89,7 +89,7 @@ def get_prs(pull_request_items: list[dict], label: str = "", state: str = "all") Args: pull_request_items (list[dict]): List of PR items. - label (str): The label name. + label (str): The label name. Filter is not applied when empty string. state (str): State of PR, e.g. open, closed, all Returns: @@ -99,11 +99,11 @@ def get_prs(pull_request_items: list[dict], label: str = "", state: str = "all") pr_list = [] count = 0 for pr in pull_request_items: - if pr["state"] == state and [item for item in pr["labels"] if item["name"] == label]: + if state in [pr["state"], "all"] and (not label or [item for item in pr["labels"] if item["name"] == label]): pr_list.append(pr) count += 1 - print(f"Found {count} PRs with {label if label else 'no'} label and state as {state}") + print(f"Found {count} PRs with {label if label else 'no filter on'} label and state as {state}") return pr_list @@ -113,7 +113,7 @@ def get_prs_assignees(pull_request_items: list[dict], label: str = "", state: st Args: pull_request_items (list[dict]): List of PR items. - label (str): The label name. + label (str): The label name. Filter is not applied when empty string. state (str): State of PR, e.g. open, closed, all Returns: @@ -123,10 +123,10 @@ def get_prs_assignees(pull_request_items: list[dict], label: str = "", state: st """ assignee_list = [] for pr in pull_request_items: - if pr["state"] == state and [item for item in pr["labels"] if not label or item["name"] == label]: + if state in [pr["state"], "all"] and (not label or [item for item in pr["labels"] if item["name"] == label]): [assignee_list.append(assignee["login"]) for assignee in pr["assignees"] if assignee["login"] != "jjw24" ] - print(f"Found {len(assignee_list)} assignees with {label if label else 'no'} label and state as {state}") + print(f"Found {len(assignee_list)} assignees with {label if label else 'no filter on'} label and state as {state}") return assignee_list