diff options
author | Zuul <zuul@review.openstack.org> | 2018-01-08 21:35:40 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2018-01-08 21:35:40 +0000 |
commit | cb3fc8dbd98048045833d9fd8402638c3613bc7d (patch) | |
tree | 9db99931d87233517eef4dde86900cf6319c9300 | |
parent | f7f5bf4b1965198f636a010da625c5ef8db86309 (diff) | |
parent | 42f7d6f10084151d8aecb014effdde6eefa6ed8e (diff) | |
download | zuul-cb3fc8dbd98048045833d9fd8402638c3613bc7d.tar.gz |
Merge "Correctly use project name in getGitUrl" into feature/zuulv3
-rw-r--r-- | tests/unit/test_github_driver.py | 15 | ||||
-rw-r--r-- | zuul/driver/github/githubconnection.py | 12 |
2 files changed, 18 insertions, 9 deletions
diff --git a/tests/unit/test_github_driver.py b/tests/unit/test_github_driver.py index ebb5e1c85..6ab1a2650 100644 --- a/tests/unit/test_github_driver.py +++ b/tests/unit/test_github_driver.py @@ -243,19 +243,28 @@ class TestGithubDriver(ZuulTestCase): @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 62dd45ce7..041ea345a 100644 --- a/zuul/driver/github/githubconnection.py +++ b/zuul/driver/github/githubconnection.py @@ -35,7 +35,7 @@ import github3 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 @@ -795,17 +795,17 @@ class GithubConnection(BaseConnection): 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) |