Merge "Add getProjectBranches to Source" into feature/zuulv3
diff --git a/zuul/configloader.py b/zuul/configloader.py
index 3f723fb..fa526c1 100644
--- a/zuul/configloader.py
+++ b/zuul/configloader.py
@@ -551,7 +551,11 @@
# 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
diff --git a/zuul/connection/gerrit.py b/zuul/connection/gerrit.py
index 4ebdd56..f084993 100644
--- a/zuul/connection/gerrit.py
+++ b/zuul/connection/gerrit.py
@@ -571,6 +571,12 @@
(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))
diff --git a/zuul/source/__init__.py b/zuul/source/__init__.py
index d92d47a..69dc162 100644
--- a/zuul/source/__init__.py
+++ b/zuul/source/__init__.py
@@ -63,3 +63,7 @@
@abc.abstractmethod
def getProject(self, name):
"""Get a project."""
+
+ @abc.abstractmethod
+ def getProjectBranches(self, project):
+ """Get branches for a project"""
diff --git a/zuul/source/gerrit.py b/zuul/source/gerrit.py
index 85227c7..8b03135 100644
--- a/zuul/source/gerrit.py
+++ b/zuul/source/gerrit.py
@@ -41,6 +41,9 @@
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)