| |
@@ -1279,25 +1279,45 @@
|
| |
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 |
|
| |
- +--------------------+----------+---------------+----------------------+
|
| |
- | ``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
|
| |
^^^^^^^^^^^^^^^
|
| |
@@ -1349,11 +1369,26 @@
|
| |
}
|
| |
}
|
| |
|
| |
- """
|
| |
+ """ # noqa
|
| |
|
| |
- repo = _get_repo(repo, username, namespace)
|
| |
- _check_pull_request(repo)
|
| |
- _check_token(repo)
|
| |
+ repo_to = _get_repo(repo, username, namespace)
|
| |
+
|
| |
+ 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,
|
| |
+ username=repo_from_username,
|
| |
+ namespace=repo_from_namespace,
|
| |
+ )
|
| |
+ else:
|
| |
+ repo_from = repo_to
|
| |
+
|
| |
+ _check_pull_request(repo_to)
|
| |
+ _check_token(repo_from)
|
| |
|
| |
form = pagure.forms.RequestPullForm(csrf_enabled=False)
|
| |
if not form.validate_on_submit():
|
| |
@@ -1375,35 +1410,31 @@
|
| |
errors={"branch_from": ["This field is required."]},
|
| |
)
|
| |
|
| |
- parent = repo
|
| |
- if repo.parent:
|
| |
- parent = repo.parent
|
| |
-
|
| |
- if not parent.settings.get("pull_requests", True):
|
| |
+ if not repo_to.settings.get("pull_requests", True):
|
| |
raise pagure.exceptions.APIError(
|
| |
404, error_code=APIERROR.EPULLREQUESTSDISABLED
|
| |
)
|
| |
|
| |
- repo_committer = pagure.utils.is_repo_committer(repo)
|
| |
+ repo_committer = pagure.utils.is_repo_committer(repo_from)
|
| |
|
| |
if not repo_committer:
|
| |
raise pagure.exceptions.APIError(
|
| |
401, error_code=APIERROR.ENOTHIGHENOUGH
|
| |
)
|
| |
|
| |
- repo_obj = pygit2.Repository(repo.repopath("main"))
|
| |
- orig_repo = pygit2.Repository(parent.repopath("main"))
|
| |
+ git_repo_from = pygit2.Repository(repo_from.repopath("main"))
|
| |
+ git_repo_to = pygit2.Repository(repo_to.repopath("main"))
|
| |
|
| |
try:
|
| |
diff, diff_commits, orig_commit = pagure.lib.git.get_diff_info(
|
| |
- repo_obj, orig_repo, branch_from, branch_to
|
| |
+ git_repo_from, git_repo_to, branch_from, branch_to
|
| |
)
|
| |
except pagure.exceptions.PagureException as err:
|
| |
raise pagure.exceptions.APIError(
|
| |
400, error_code=APIERROR.EINVALIDREQ, errors=str(err)
|
| |
)
|
| |
|
| |
- if parent.settings.get(
|
| |
+ if repo_to.settings.get(
|
| |
"Enforce_signed-off_commits_in_pull-request", False
|
| |
):
|
| |
for commit in diff_commits:
|
| |
@@ -1424,10 +1455,10 @@
|
| |
|
| |
request = pagure.lib.query.new_pull_request(
|
| |
flask.g.session,
|
| |
- repo_to=parent,
|
| |
+ repo_to=repo_to,
|
| |
branch_to=branch_to,
|
| |
branch_from=branch_from,
|
| |
- repo_from=repo,
|
| |
+ repo_from=repo_from,
|
| |
title=form.title.data,
|
| |
initial_comment=initial_comment,
|
| |
user=flask.g.fas_user.username,
|
| |
@@ -1577,7 +1608,7 @@
|
| |
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)
|
| |
New argument
repo_from
added. Now it is possible to open a pull request from fork to a another fork (of the same parent) or to a parent.The
repo_from
is expected to be a dictionary, example:{'username': 'foo', 'namespace': None, 'repo': 'carrot'}
I also added the
__repr__
function of a class Project in pagure/lib/model.py. The other classes have__repr__
and here it was handy too.