#4452 [WIP] Add repo_from argument for API create pull request
Merged by pingou. Opened by lenkaseg.
Unknown source master

Download 4452.patch

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.

Relates to PR #4424 and Issue #4416

With the .get("repo_from") above the variable repo_from_d may be None which means this line will explode

Let's remove these two changes (ie: keep the empty lines), they do not relate to this PR :)

I think this is a good start :)

I expect we'll need to adjust some of the tests :)

Let's remove these two changes (ie: keep the empty lines), they do not relate to this PR :)

Ah, yes, that's a residue after removing a ton of prints :)

rebased onto 54f6fe4b1523e593e3e31828ab2606bf3f4ccf97

Does this fix it?

You could just check the value of repo_from_d, no? :)

You could just check the value of repo_from_d, no? :)

Ok, I'll redo it.

2 new commits added

  • Adjust how are passed the arguments about repo_from when opening a new PR
  • Code style changes and documentation

pretty please pagure-ci rebuild

pretty please pagure-ci rebuild

pretty please pagure-ci rebuild

All the tests pass when I run them in my environment, except the test_style, but that one fails on stuff which is not part of this PR.

rebased onto 5f4a7cd5ca662a3f2879602dfab18547ed85b68f

Rebased on master.

This is what I had to change to make the tests pass:

diff --git a/ pagure/api/fork.py b/ pagure/api/fork.py
index 7ef0a408..9dc6a872 100644
--- a/ pagure/api/fork.py       
+++ b/ pagure/api/fork.py       
@@ -1369,7 +1369,7 @@ def api_pull_request_create(repo, username=None, namespace=None):
           }
         }
-    """
+    """  # noqa
     repo_to = _get_repo(repo, username, namespace)
diff --git a/ tests/test_pagure_flask_api_fork.py b/ tests/test_pagure_flask_api_fork.py
index 8a601a3a..90c0cfc4 100644
--- a/ tests/test_pagure_flask_api_fork.py      
+++ b/ tests/test_pagure_flask_api_fork.py      
@@ -2815,9 +2815,7 @@ class PagureFlaskApiForktests(tests.Modeltests):
         }
         output = self.app.post(
-            "/api/0/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 96965fce..31dcda65 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)

3 new commits added

  • Adjust how are passed the arguments about repo_from when opening a new PR
  • Code style changes and documentation
  • Add repo_from argument for API create pull request

rebased onto 98b37a4ca8b1bb434a495fb013d5010465dc3b7b

Missing a space before the # noqa, there should be two, not one :)

3 new commits added

  • Adjust how are passed the arguments about repo_from when opening a new PR
  • Code style changes and documentation
  • Add repo_from argument for API create pull request

Thanks for your work! :)

Pull-Request has been merged by pingou

Thanks for your help! :)

Metadata