mirror of
https://github.com/All-Hands-AI/OpenHands.git
synced 2026-01-09 14:57:59 -05:00
fix:Transmitting accurate head parameter in cross-repository pull requests. (#7788)
This commit is contained in:
@@ -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',
|
||||
}
|
||||
|
||||
@@ -558,7 +558,7 @@ def test_send_pull_request_target_branch_with_fork(
|
||||
post_data = mock_post.call_args[1]['json']
|
||||
assert post_data['base'] == target_branch # PR should target the specified branch
|
||||
assert (
|
||||
post_data['head'] == 'openhands-fix-issue-42'
|
||||
post_data['head'] == 'fork-owner:openhands-fix-issue-42'
|
||||
) # Branch name should be standard
|
||||
|
||||
# Check that push was to fork
|
||||
|
||||
Reference in New Issue
Block a user