From b9d537183722c7466a76b48f342f9b6631ada0e9 Mon Sep 17 00:00:00 2001
From: Pierre-Yves Chibon <pingou@pingoured.fr>
Date: Feb 20 2018 09:24:58 +0000
Subject: [PATCH 1/3] Fix call to get_remote_repo_path


This function has been moved to pagure.utils but these calls had not
been updated.

Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr>

---

diff --git a/pagure/lib/tasks.py b/pagure/lib/tasks.py
index ecfe230..a5249b4 100644
--- a/pagure/lib/tasks.py
+++ b/pagure/lib/tasks.py
@@ -589,8 +589,9 @@ def pull_remote_repo(self, remote_git, branch_from):
     """ Clone a remote git repository locally for remote PRs.
     """
 
-    clonepath = pagure.get_remote_repo_path(remote_git, branch_from,
-                                            ignore_non_exist=True)
+    clonepath = pagure.utils.get_remote_repo_path(
+        remote_git, branch_from, ignore_non_exist=True)
+
     repo = pygit2.clone_repository(
         remote_git, clonepath, checkout_branch=branch_from)
 
@@ -617,8 +618,8 @@ def refresh_remote_pr(self, name, namespace, user, requestid):
         'refreshing remote pull-request: %s/#%s', request.project.fullname,
         request.id)
 
-    clonepath = pagure.get_remote_repo_path(request.remote_git,
-                                            request.branch_from)
+    clonepath = pagure.utils.utils.get_remote_repo_path(
+        request.remote_git, request.branch_from)
 
     repo = pagure.lib.repo.PagureRepo(clonepath)
     repo.pull(branch=request.branch_from, force=True)
@@ -754,7 +755,7 @@ def sync_pull_ref(self, name, namespace, user, requestid):
 
         if request.remote:
             # Get the fork
-            repopath = pagure.get_remote_repo_path(
+            repopath = pagure.utils.get_remote_repo_path(
                 request.remote_git, request.branch_from)
         else:
             # Get the fork
diff --git a/pagure/ui/fork.py b/pagure/ui/fork.py
index 70118dc..40eda16 100644
--- a/pagure/ui/fork.py
+++ b/pagure/ui/fork.py
@@ -320,7 +320,7 @@ def request_pull_to_diff_or_patch(
         flask.abort(404, 'Pull-request not found')
 
     if request.remote:
-        repopath = pagure.get_remote_repo_path(
+        repopath = pagure.utils.get_remote_repo_path(
             request.remote_git, request.branch_from)
         parentpath = pagure.utils.get_repo_path(request.project)
     else:
@@ -1276,7 +1276,7 @@ def new_remote_request_pull(repo, username=None, namespace=None):
         branch_to = form.branch_to.data.strip()
         remote_git = form.git_repo.data.strip()
 
-        repopath = pagure.get_remote_repo_path(remote_git, branch_from)
+        repopath = pagure.utils.get_remote_repo_path(remote_git, branch_from)
         if not repopath:
             taskid = pagure.lib.tasks.pull_remote_repo.delay(
                 remote_git, branch_from)

From fce16ecbdbfdb030c570759656fdcfe991cf1924 Mon Sep 17 00:00:00 2001
From: Pierre-Yves Chibon <pingou@pingoured.fr>
Date: Feb 20 2018 09:24:58 +0000
Subject: [PATCH 2/3] Fix the endpoint now that they should be blueprints


Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr>

---

diff --git a/pagure/ui/fork.py b/pagure/ui/fork.py
index 40eda16..c5e05c0 100644
--- a/pagure/ui/fork.py
+++ b/pagure/ui/fork.py
@@ -1267,7 +1267,7 @@ def new_remote_request_pull(repo, username=None, namespace=None):
             result = pagure.lib.tasks.get_result(taskid)
             if not result.ready:
                 return pagure.utils.wait_for_task_post(
-                    taskid, form, 'new_remote_request_pull',
+                    taskid, form, 'ui_ns.new_remote_request_pull',
                     repo=repo.name, username=username, namespace=namespace)
             # Make sure to collect any exceptions resulting from the task
             result.get(timeout=0)
@@ -1281,7 +1281,7 @@ def new_remote_request_pull(repo, username=None, namespace=None):
             taskid = pagure.lib.tasks.pull_remote_repo.delay(
                 remote_git, branch_from)
             return pagure.utils.wait_for_task_post(
-                taskid, form, 'new_remote_request_pull',
+                taskid, form, 'ui_ns.new_remote_request_pull',
                 repo=repo.name, username=username, namespace=namespace,
                 initial=True)
 

From 67fb4461fc8378051bc5091733aa2adf2d6a6739 Mon Sep 17 00:00:00 2001
From: Pierre-Yves Chibon <pingou@pingoured.fr>
Date: Feb 20 2018 09:24:58 +0000
Subject: [PATCH 3/3] Catch exceptions thrown by the task and return it to the user


Fixes https://pagure.io/fedora-infrastructure/issue/6700

Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr>

---

diff --git a/pagure/ui/fork.py b/pagure/ui/fork.py
index c5e05c0..54beaa0 100644
--- a/pagure/ui/fork.py
+++ b/pagure/ui/fork.py
@@ -1270,7 +1270,10 @@ def new_remote_request_pull(repo, username=None, namespace=None):
                     taskid, form, 'ui_ns.new_remote_request_pull',
                     repo=repo.name, username=username, namespace=namespace)
             # Make sure to collect any exceptions resulting from the task
-            result.get(timeout=0)
+            try:
+                result.get(timeout=0)
+            except Exception as err:
+                flask.abort(500, err)
 
         branch_from = form.branch_from.data.strip()
         branch_to = form.branch_to.data.strip()

