Merge "Add getProjectBranches to Source" into feature/zuulv3

This commit is contained in:
Jenkins 2016-11-09 18:59:03 +00:00 committed by Gerrit Code Review
commit 86d2f726be
4 changed files with 18 additions and 1 deletions

View File

@ -551,7 +551,11 @@ class TenantParser(object):
# Get in-project-repo config files which have a restricted
# set of options.
url = source.getGitUrl(project)
# TODOv3(jeblair): config should be branch specific
# TODOv3(jeblair): config should be branch specific. For
# each branch in the repo, get the zuul.yaml for that
# branch. Remember the branch and then implicitly add a
# branch selector to each job there.
source.getProjectBranches(project)
job = merger.getFiles(project.name, url, 'master',
files=['.zuul.yaml'])
job.project = project

View File

@ -571,6 +571,12 @@ class GerritConnection(BaseConnection):
(record.get('number'),))
return changes
def getProjectBranches(self, project):
refs = self.getInfoRefs(project)
heads = [str(k[len('refs/heads/'):]) for k in refs.keys()
if k.startswith('refs/heads/')]
return heads
def addEvent(self, data):
return self.event_queue.put((time.time(), data))

View File

@ -63,3 +63,7 @@ class BaseSource(object):
@abc.abstractmethod
def getProject(self, name):
"""Get a project."""
@abc.abstractmethod
def getProjectBranches(self, project):
"""Get branches for a project"""

View File

@ -41,6 +41,9 @@ class GerritSource(BaseSource):
def getProjectOpenChanges(self, project):
return self.connection.getProjectOpenChanges(project)
def getProjectBranches(self, project):
return self.connection.getProjectBranches(project)
def getGitUrl(self, project):
return self.connection.getGitUrl(project)