fix:Transmitting accurate head parameter in cross-repository pull requests. (#7788)

This commit is contained in:
sumeetkumar1701
2025-04-14 23:27:15 +05:30
committed by GitHub
parent 33caf5c6ca
commit 2d599349ef
2 changed files with 8 additions and 2 deletions

View File

@@ -319,6 +319,12 @@ def send_pull_request(
pr_body += f'\n\n{additional_message}'
pr_body += '\n\nAutomatic fix generated by [OpenHands](https://github.com/All-Hands-AI/OpenHands/) 🙌'
# For cross repo pull request, we need to send head parameter like fork_owner:branch as per git documentation here : https://docs.github.com/en/rest/pulls/pulls?apiVersion=2022-11-28#create-a-pull-request
# head parameter usage : The name of the branch where your changes are implemented. For cross-repository pull requests in the same network, namespace head with a user like this: username:branch.
if fork_owner and platform == Platform.GITHUB:
head_branch = f'{fork_owner}:{branch_name}'
else:
head_branch = branch_name
# If we are not sending a PR, we can finish early and return the
# URL for the user to open a PR manually
if pr_type == 'branch':
@@ -328,7 +334,7 @@ def send_pull_request(
data = {
'title': final_pr_title,
('body' if platform == Platform.GITHUB else 'description'): pr_body,
('head' if platform == Platform.GITHUB else 'source_branch'): branch_name,
('head' if platform == Platform.GITHUB else 'source_branch'): head_branch,
('base' if platform == Platform.GITHUB else 'target_branch'): base_branch,
'draft': pr_type == 'draft',
}