Skip to content

Commit 64940fa

Browse files
committed
Use author if they are GitHub staff
1 parent 4bf6fa4 commit 64940fa

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

.github/update-release-branch.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,9 @@ def open_pr(
7171
body.append('')
7272
body.append('Contains the following pull requests:')
7373
for pr in pull_requests:
74-
merger = get_merger_of_pr(repo, pr)
75-
body.append(f'- #{pr.number} (@{merger})')
74+
# Use PR author if they are GitHub staff, otherwise use the merger
75+
display_user = get_pr_author_if_staff(pr) or get_merger_of_pr(repo, pr)
76+
body.append(f'- #{pr.number} (@{display_user})')
7677

7778
# List all commits not part of a PR
7879
if len(commits_without_pull_requests) > 0:
@@ -168,6 +169,17 @@ def get_pr_for_commit(commit):
168169
def get_merger_of_pr(repo, pr):
169170
return repo.get_commit(pr.merge_commit_sha).author.login
170171

172+
# Get the PR author if they are GitHub staff, otherwise None.
173+
def get_pr_author_if_staff(pr):
174+
if pr.user is None:
175+
return None
176+
try:
177+
if getattr(pr.user, 'site_admin', False):
178+
return pr.user.login
179+
except Exception:
180+
pass
181+
return None
182+
171183
def get_current_version():
172184
with open('package.json', 'r') as f:
173185
return json.load(f)['version']
@@ -181,9 +193,9 @@ def replace_version_package_json(prev_version, new_version):
181193
print(line.replace(prev_version, new_version), end='')
182194
else:
183195
prev_line_is_codeql = False
184-
print(line, end='')
196+
print(line, end='')
185197
if '\"name\": \"codeql\",' in line:
186-
prev_line_is_codeql = True
198+
prev_line_is_codeql = True
187199

188200
def get_today_string():
189201
today = datetime.datetime.today()

0 commit comments

Comments
 (0)