diff --git a/pagure/api/fork.py b/pagure/api/fork.py index 23e1461..0f0ba2d 100644 --- a/pagure/api/fork.py +++ b/pagure/api/fork.py @@ -1279,45 +1279,45 @@ def api_pull_request_create(repo, username=None, namespace=None): Input ^^^^^ - +-------------------------+----------+-------------+------------------------+ - | Key | Type | Optionality | Description | - +=========================+==========+=============+========================+ - | ``title`` | string | Mandatory | The title to give to | - | | | | this pull-request | - +-------------------------+----------+-------------+------------------------+ - | ``branch_to`` | string | Mandatory | The name of the branch | - | | | | the submitted changes | - | | | | should be merged into. | - +-------------------------+----------+-------------+------------------------+ - | ``branch_from`` | string | Mandatory | The name of the branch | - | | | | containing the changes | - | | | | to merge | - +-------------------------+----------+-------------+------------------------+ - | ``repo_from`` | string | Optional | The name of the project| - | | | | the changes originate | - | | | | from. | - | | | | If not specified the | - | | | | repo_from is assumed | - | | | | to be the repo_to. | - +-------------------------+----------+-------------+------------------------+ - | ``repo_from_username`` | string | Optional | The username of the | - | | | | project the changes | - | | | | originate from. | - | | | | If not specified the | - | | | | repo_from is assumed | - | | | | to be the repo_to. | - +-------------------------+----------+-------------+------------------------+ - | ``repo_from_namespace`` | string | Optional | The namespace of the | - | | | | project the changes | - | | | | originate from. | - | | | | If not specified the | - | | | | repo_from is assumed | - | | | | to be the repo_to. | - +-------------------------+----------+-------------+------------------------+ - | ``initial_comment`` | string | Optional | The intial comment | - | | | | describing what these | - | | | | changes are about. | - +-------------------------+----------+-------------+------------------------+ + +-----------------------+----------+-------------+------------------------+ + | Key | Type | Optionality | Description | + +=======================+==========+=============+========================+ + | ``title`` | string | Mandatory | The title to give to | + | | | | this pull-request | + +-----------------------+----------+-------------+------------------------+ + | ``branch_to`` | string | Mandatory | The name of the branch | + | | | | the submitted changes | + | | | | should be merged into. | + +-----------------------+----------+-------------+------------------------+ + | ``branch_from`` | string | Mandatory | The name of the branch | + | | | | containing the changes | + | | | | to merge | + +-----------------------+----------+-------------+------------------------+ + | ``repo_from`` | string | Optional | The name of the project| + | | | | the changes originate | + | | | | from. | + | | | | If not specified the | + | | | | repo_from is assumed | + | | | | to be the repo_to. | + +-----------------------+----------+-------------+------------------------+ + | ``repo_from_username``| string | Optional | The username of the | + | | | | project the changes | + | | | | originate from. | + | | | | If not specified the | + | | | | repo_from is assumed | + | | | | to be the repo_to. | + +-----------------------+----------+-------------+------------------------+ + |``repo_from_namespace``| string | Optional | The namespace of the | + | | | | project the changes | + | | | | originate from. | + | | | | If not specified the | + | | | | repo_from is assumed | + | | | | to be the repo_to. | + +-----------------------+----------+-------------+------------------------+ + | ``initial_comment`` | string | Optional | The intial comment | + | | | | describing what these | + | | | | changes are about. | + +-----------------------+----------+-------------+------------------------+ Sample response ^^^^^^^^^^^^^^^ @@ -1369,18 +1369,20 @@ def api_pull_request_create(repo, username=None, namespace=None): } } - """ + """ # noqa repo_to = _get_repo(repo, username, namespace) - repo_from_d = get_request_data().get("repo_from") - if repo_from_d and repo_from_d.get("repo"): - print(repo_from_d) - print('='*50) + req_data = get_request_data() + repo_from = req_data.get("repo_from") + repo_from_username = req_data.get("repo_from_username") + repo_from_namespace = req_data.get("repo_from_namespace") + + if repo_from: repo_from = _get_repo( - repo_from_d["repo"], - repo_from_d.get("username"), - repo_from_d.get("namespace"), + repo_from, + username=repo_from_username, + namespace=repo_from_namespace, ) else: repo_from = repo_to @@ -1606,7 +1608,7 @@ def api_pull_request_diffstats(repo, requestid, username=None, namespace=None): for patch in diff: stats = pagure.lib.git.get_stats_patch(patch) new_path = stats["new_path"] - del (stats["new_path"]) + del stats["new_path"] output[new_path] = stats else: raise pagure.exceptions.APIError(400, error_code=APIERROR.ENOPRSTATS) diff --git a/tests/test_pagure_flask_api_fork.py b/tests/test_pagure_flask_api_fork.py index b53759c..90c0cfc 100644 --- a/tests/test_pagure_flask_api_fork.py +++ b/tests/test_pagure_flask_api_fork.py @@ -2810,12 +2810,12 @@ class PagureFlaskApiForktests(tests.Modeltests): "initial_comment": "the manifest", "branch_to": "master", "branch_from": "branch", + "repo_from": "test", + "repo_from_username": "pingou", } output = self.app.post( - "/api/0/fork/pingou/test/pull-request/new", - headers=headers, - data=data, + "/api/0/test/pull-request/new", headers=headers, data=data ) self.assertEqual(output.status_code, 200) diff --git a/tests/test_pagure_flask_ui_repo.py b/tests/test_pagure_flask_ui_repo.py index 96965fc..31dcda6 100644 --- a/tests/test_pagure_flask_ui_repo.py +++ b/tests/test_pagure_flask_ui_repo.py @@ -6757,9 +6757,7 @@ class PagureFlaskRepoTestHooktests(tests.Modeltests): """ Test the test_hook endpoint when the user is logged in. """ user = tests.FakeUser(username="pingou") with tests.user_set(self.app.application, user): - data = { - "csrf_token": self.get_csrf() - } + data = {"csrf_token": self.get_csrf()} output = self.app.post("/test/settings/test_hook", data=data) self.assertEqual(output.status_code, 302)