Skip to content

Commit

Permalink
action: Fix the detection of changes requested in a PR
Browse files Browse the repository at this point in the history
The GitHub API returns all reviews posted in chronological order.
Accumulate the reviews per-user in a dictionary before checking if there
are any changes requested.

Signed-off-by: Carles Cufi <[email protected]>
  • Loading branch information
carlescufi committed Nov 13, 2024
1 parent 0b028e1 commit ee12122
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion action.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,11 @@ def fetch_pr(repo, prn, target):
if pr.state == 'closed':
die(f'PR #{prn} is closed and not merged')

revs = dict()
for rev in pr.get_reviews():
if "CHANGES_REQUESTED" in rev.state:
revs[rev.user.login] = rev.state
for k,v in revs.items():
if "CHANGES_REQUESTED" in v:
die(f'PR #{prn} has requested changes')

shas = [c.sha for c in pr.get_commits()]
Expand Down

0 comments on commit ee12122

Please sign in to comment.