Skip to content

Commit

Permalink
formatting: conditionally include ref owners in PR output
Browse files Browse the repository at this point in the history
If PR head branch is from a different repo (fork), include owner names
in the refs. Otherwise, just stick to the branch names only.
  • Loading branch information
dgw committed Jun 27, 2020
1 parent 7f3e3bd commit 68f282a
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions sopel_modules/github/formatting.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,9 +342,6 @@ def fmt_pull_request_summary_message(payload=None):
if not payload:
payload = current_payload

base_ref = payload['pull_request']['base']['label'].split(':')[-1]
head_ref = payload['pull_request']['head']['label'].split(':')[-1]

action = payload['action']
if action == 'closed' and payload['pull_request']['merged']:
action = 'merged'
Expand All @@ -359,15 +356,23 @@ def fmt_pull_request_summary_message(payload=None):
if action == 'merged' and actor != author:
maybe_possessive = '%s\'s ' % author

base = fmt_branch(payload['pull_request']['base']['ref'])
head = fmt_branch(payload['pull_request']['head']['ref'])
base_repo = payload['pull_request']['base']['user']['login']
head_repo = payload['pull_request']['base']['user']['login']
if base_repo != head_repo:
base = "{}:{}".format(fmt_name(base_repo), base)
head = "{}:{}".format(fmt_name(head_repo), head)

return '[{}] {} {} {}pull request #{}: {} ({}...{})'.format(
fmt_repo(payload['repository']['name']),
fmt_name(actor),
action,
maybe_possessive,
payload['pull_request']['number'],
emojize(payload['pull_request']['title']),
fmt_branch(base_ref),
fmt_branch(head_ref))
base,
head)


def fmt_pull_request_title_edit(payload=None):
Expand Down

0 comments on commit 68f282a

Please sign in to comment.