Skip to content

Commit c541814

Browse files
Discover the clone url of pagure repository
This fixes git pull-request with pagure hosts that use the real user name instead of "git".
1 parent ca21968 commit c541814

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

git_pull_request/pagure.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,15 @@ def enable_pull_request(self, project):
9191
options = {"pull_requests": True}
9292
self.post("%s/options/update" % project, options)
9393

94-
def create_fork(self, _):
95-
class ForkedRepo:
96-
clone_url = "ssh://git@%s/forks/%s/%s.git" % (
97-
self.host, self.user, self.reponame_to_fork)
98-
html_url = "https://%s/%s" % (self.host, self.fork_path)
94+
def get_repo_urls(self, reponame):
95+
urls = self.get("{}/git/urls".format(reponame))["urls"]
96+
if "ssh" not in urls:
97+
raise RuntimeError("%s: no ssh urls to push" % self.reponame)
98+
return type('ForkedRepo', (object,), dict(
99+
clone_url=urls["ssh"].format(username=self.user),
100+
html_url=urls["git"]))
99101

102+
def create_fork(self, _):
100103
LOG.debug("check if the fork already exists")
101104
if not self.get(self.fork_path, error_ok=True):
102105
LOG.info("requesting a fork creation")
@@ -109,7 +112,7 @@ class ForkedRepo:
109112
self.post("fork",
110113
{"repo": repo, "namespace": namespace, "wait": True})
111114
self.enable_pull_request(self.fork_path)
112-
return ForkedRepo
115+
return self.get_repo_urls(self.fork_path)
113116

114117
def get_pulls(self, base, head):
115118
class Pull:

0 commit comments

Comments
 (0)