Correctly use project name in getGitUrl
The method getGitUrl is called via the project object and not
string. While this doesn't matter when adding it to a string this
breaks lookup of the installation key.
Change-Id: I6632497af0b1e13f6e77b5b7b0a0ee105215a1f9
diff --git a/tests/unit/test_github_driver.py b/tests/unit/test_github_driver.py
index ebb5e1c..6ab1a26 100644
--- a/tests/unit/test_github_driver.py
+++ b/tests/unit/test_github_driver.py
@@ -243,19 +243,28 @@
@simple_layout('layouts/basic-github.yaml', driver='github')
def test_git_https_url(self):
"""Test that git_ssh option gives git url with ssh"""
- url = self.fake_github.real_getGitUrl('org/project')
+ tenant = self.sched.abide.tenants.get('tenant-one')
+ _, project = tenant.getProject('org/project')
+
+ url = self.fake_github.real_getGitUrl(project)
self.assertEqual('https://github.com/org/project', url)
@simple_layout('layouts/basic-github.yaml', driver='github')
def test_git_ssh_url(self):
"""Test that git_ssh option gives git url with ssh"""
- url = self.fake_github_ssh.real_getGitUrl('org/project')
+ tenant = self.sched.abide.tenants.get('tenant-one')
+ _, project = tenant.getProject('org/project')
+
+ url = self.fake_github_ssh.real_getGitUrl(project)
self.assertEqual('ssh://git@github.com/org/project.git', url)
@simple_layout('layouts/basic-github.yaml', driver='github')
def test_git_enterprise_url(self):
"""Test that git_url option gives git url with proper host"""
- url = self.fake_github_ent.real_getGitUrl('org/project')
+ tenant = self.sched.abide.tenants.get('tenant-one')
+ _, project = tenant.getProject('org/project')
+
+ url = self.fake_github_ent.real_getGitUrl(project)
self.assertEqual('ssh://git@github.enterprise.io/org/project.git', url)
@simple_layout('layouts/reporting-github.yaml', driver='github')
diff --git a/zuul/driver/github/githubconnection.py b/zuul/driver/github/githubconnection.py
index f987f47..0c8ac2e 100644
--- a/zuul/driver/github/githubconnection.py
+++ b/zuul/driver/github/githubconnection.py
@@ -34,7 +34,7 @@
import github3.exceptions
from zuul.connection import BaseConnection
-from zuul.model import Ref, Branch, Tag
+from zuul.model import Ref, Branch, Tag, Project
from zuul.exceptions import MergeFailure
from zuul.driver.github.githubmodel import PullRequest, GithubTriggerEvent
@@ -786,17 +786,17 @@
return change
- def getGitUrl(self, project):
+ def getGitUrl(self, project: Project):
if self.git_ssh_key:
- return 'ssh://git@%s/%s.git' % (self.server, project)
+ return 'ssh://git@%s/%s.git' % (self.server, project.name)
if self.app_id:
- installation_key = self._get_installation_key(project)
+ installation_key = self._get_installation_key(project.name)
return 'https://x-access-token:%s@%s/%s' % (installation_key,
self.server,
- project)
+ project.name)
- return 'https://%s/%s' % (self.server, project)
+ return 'https://%s/%s' % (self.server, project.name)
def getGitwebUrl(self, project, sha=None):
url = 'https://%s/%s' % (self.server, project)