integration: Modify branch names on pull request events.

Previously when Github bot receives an update pull request event,it
will produce the following message:

user updated PR #1 Start writing unit tests from test to main

"from test to main" is improper and causes unnecessary confusion.
These changes will update the logic to remove the phrase from
update events. These changes will also include the org: prefix to
the branch names to keep it consistent with Github and further
reduce confusions on branch names.

Fixes #24536.
This commit is contained in:
Joelute
2023-03-13 16:54:41 -04:00
committed by Tim Abbott
parent c446f86173
commit 869cb6dc34
2 changed files with 16 additions and 9 deletions

View File

@@ -73,13 +73,18 @@ def get_opened_or_update_pull_request_body(helper: Helper) -> str:
changes = payload.get("changes", {})
if "body" in changes or action == "opened":
description = pull_request["body"].tame(check_none_or(check_string))
target_branch = None
base_branch = None
if action == "opened" or action == "merged":
target_branch = pull_request["head"]["label"].tame(check_string)
base_branch = pull_request["base"]["label"].tame(check_string)
return get_pull_request_event_message(
get_sender_name(payload),
action,
pull_request["html_url"].tame(check_string),
target_branch=pull_request["head"]["ref"].tame(check_string),
base_branch=pull_request["base"]["ref"].tame(check_string),
target_branch=target_branch,
base_branch=base_branch,
message=description,
assignee=assignee,
number=pull_request["number"].tame(check_int),