Skip to content
Merged
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
13 changes: 13 additions & 0 deletions .github/scripts/propose_ghstack_orig_pr.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,17 @@ def get_pr_stack_from_number(ref: str, repo: Repository) -> List[int]:
return pr_stack


def get_differential_revision(pr, repo: Repository) -> str:
body = repo.get_pull(pr.number).body
matches = re.findall(r"Differential Revision: .*", body)
count = len(matches)
if count == 1:
# If there's more than one Differential Revision, let's just return empty
# so that we can disambiguate manually.
return matches[0]
return ""


def create_prs_for_orig_branch(pr_stack: List[int], repo: Repository):
# For the first PR, we want to merge to `main` branch, and we will update
# as we go through the stack
Expand All @@ -100,13 +111,15 @@ def create_prs_for_orig_branch(pr_stack: List[int], repo: Repository):
# The PR we want to create is then "branch_to_merge" <- gh/user/x/orig
# gh/user/x/orig is the clean diff between gh/user/x/base <- gh/user/x/head
orig_branch_merge_head = pr.base.ref.replace("base", "orig")
differential_revision_text = get_differential_revision(pr, repo)
bot_metadata = f"""This PR was created by the merge bot to help merge the original PR into the main branch.
ghstack PR number: https://github.com/pytorch/executorch/pull/{pr.number} by @{pr.user.login}
^ Please use this as the source of truth for the PR details, comments, and reviews
ghstack PR base: https://github.com/pytorch/executorch/tree/{pr.base.ref}
ghstack PR head: https://github.com/pytorch/executorch/tree/{pr.head.ref}
Merge bot PR base: https://github.com/pytorch/executorch/tree/{orig_branch_merge_base}
Merge bot PR head: https://github.com/pytorch/executorch/tree/{orig_branch_merge_head}
{differential_revision_text}
@diff-train-skip-merge"""

existing_orig_pr = repo.get_pulls(
Expand Down
Loading