π OpenHands: AI-Driven Development
fix:Transmitting accurate head parameter in cross-repository pull requests. (#7788)
sumeetkumar17012d599349efee
diff --git a/openhands/resolver/send_pull_request.py b/openhands/resolver/send_pull_request.pyindex a17bb846ee..e9513d256f 100644--- a/openhands/resolver/send_pull_request.py+++ b/openhands/resolver/send_pull_request.py@@ -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 manuallyif 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',}diff --git a/tests/unit/resolver/github/test_send_pull_request.py b/tests/unit/resolver/github/test_send_pull_request.pyindex a57c14df4c..329002f44a 100644--- a/tests/unit/resolver/github/test_send_pull_request.py+++ b/tests/unit/resolver/github/test_send_pull_request.py@@ -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 branchassert (- 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