Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions .github/update-release-branch.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,9 @@
body.append('')
body.append('Contains the following pull requests:')
for pr in pull_requests:
merger = get_merger_of_pr(repo, pr)
body.append(f'- #{pr.number} (@{merger})')
# Use PR author if they are GitHub staff, otherwise use the merger
display_user = get_pr_author_if_staff(pr) or get_merger_of_pr(repo, pr)
body.append(f'- #{pr.number} (@{display_user})')

# List all commits not part of a PR
if len(commits_without_pull_requests) > 0:
Expand Down Expand Up @@ -168,6 +169,17 @@
def get_merger_of_pr(repo, pr):
return repo.get_commit(pr.merge_commit_sha).author.login

# Get the PR author if they are GitHub staff, otherwise None.
def get_pr_author_if_staff(pr):
if pr.user is None:
return None
try:
if getattr(pr.user, 'site_admin', False):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this would throw if we're providing a default value, so I think we can remove the try/catch.

return pr.user.login
except Exception:
pass
return None

def get_current_version():
with open('package.json', 'r') as f:
return json.load(f)['version']
Expand All @@ -181,9 +193,9 @@
print(line.replace(prev_version, new_version), end='')
else:
prev_line_is_codeql = False
print(line, end='')
print(line, end='')
if '\"name\": \"codeql\",' in line:
prev_line_is_codeql = True
prev_line_is_codeql = True

def get_today_string():
today = datetime.datetime.today()
Expand Down
Loading