Skip to content

Commit 24742fc

Browse files
committed
fix filtering for state all and no label
1 parent 725b340 commit 24742fc

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

.github/update_release_pr.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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,11 +99,11 @@ 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

@@ -113,7 +113,7 @@ def get_prs_assignees(pull_request_items: list[dict], label: str = "", state: st
113113
114114
Args:
115115
pull_request_items (list[dict]): List of PR items.
116-
label (str): The label name.
116+
label (str): The label name. Filter is not applied when empty string.
117117
state (str): State of PR, e.g. open, closed, all
118118
119119
Returns:
@@ -123,10 +123,10 @@ def get_prs_assignees(pull_request_items: list[dict], label: str = "", state: st
123123
"""
124124
assignee_list = []
125125
for pr in pull_request_items:
126-
if pr["state"] == state and [item for item in pr["labels"] if not label or item["name"] == label]:
126+
if state in [pr["state"], "all"] and (not label or [item for item in pr["labels"] if item["name"] == label]):
127127
[assignee_list.append(assignee["login"]) for assignee in pr["assignees"] if assignee["login"] != "jjw24" ]
128128

129-
print(f"Found {len(assignee_list)} assignees with {label if label else 'no'} label and state as {state}")
129+
print(f"Found {len(assignee_list)} assignees with {label if label else 'no filter on'} label and state as {state}")
130130

131131
return assignee_list
132132

0 commit comments

Comments
 (0)