Browse Source

Convert some leftover changeish mentions to ref

Noticed there were a few vestigal references to Changeish that didn't get
converted, including the ChangeishFilter. Convert them to Ref.

In model, there were two places where a method started with changeish =
self.change. Those were removed and self.change was used in the method
because ref = self.change led to the method having two important
variables "ref" and "ret" which seems like a recipe for confusion. Of
course, that led to one line being too long for pep8, so it was
rewritten to use getattr instead of hasattr + and.

Change-Id: I420b8ec7c7eb32574dfe2de467fc2bbd0f96e9f1
changes/18/465718/3
Monty Taylor 4 years ago
committed by James E. Blair
parent
commit
55d0f56d61
  1. 4
      doc/source/developer/datamodel.rst
  2. 4
      zuul/configloader.py
  3. 6
      zuul/manager/__init__.py
  4. 30
      zuul/model.py

4
doc/source/developer/datamodel.rst

@ -8,7 +8,7 @@ basic organizational structure that everything else hangs off.
Pipelines have a configured
:py:class:`~zuul.manager.PipelineManager` which controlls how
the :py:class:`Change <zuul.model.Changeish>` objects are enqueued and
the :py:class:`Ref <zuul.model.Ref>` objects are enqueued and
processed.
There are currently two,
@ -35,7 +35,7 @@ objects.
.. autoclass:: zuul.model.Build
The :py:class:`~zuul.manager.base.PipelineManager` enqueues each
:py:class:`Change <zuul.model.Changeish>` into the
:py:class:`Ref <zuul.model.Ref>` into the
:py:class:`~zuul.model.ChangeQueue` in a :py:class:`~zuul.model.QueueItem`.
.. autoclass:: zuul.model.QueueItem

4
zuul/configloader.py

@ -773,12 +773,12 @@ class PipelineParser(object):
for source_name, require_config in conf.get('require', {}).items():
source = connections.getSource(source_name)
manager.changeish_filters.extend(
manager.ref_filters.extend(
source.getRequireFilters(require_config))
for source_name, reject_config in conf.get('reject', {}).items():
source = connections.getSource(source_name)
manager.changeish_filters.extend(
manager.ref_filters.extend(
source.getRejectFilters(reject_config))
for trigger_name, trigger_config in conf.get('trigger').items():

6
zuul/manager/__init__.py

@ -47,7 +47,7 @@ class PipelineManager(object):
self.sched = sched
self.pipeline = pipeline
self.event_filters = []
self.changeish_filters = []
self.ref_filters = []
def __str__(self):
return "<%s %s>" % (self.__class__.__name__, self.pipeline.name)
@ -55,7 +55,7 @@ class PipelineManager(object):
def _postConfig(self, layout):
self.log.info("Configured Pipeline Manager %s" % self.pipeline.name)
self.log.info(" Requirements:")
for f in self.changeish_filters:
for f in self.ref_filters:
self.log.info(" %s" % f)
self.log.info(" Events:")
for e in self.event_filters:
@ -281,7 +281,7 @@ class PipelineManager(object):
return False
if not ignore_requirements:
for f in self.changeish_filters:
for f in self.ref_filters:
if f.connection_name != change.project.connection_name:
self.log.debug("Filter %s skipped for change %s due "
"to mismatched connections" % (f, change))

30
zuul/model.py

@ -1280,7 +1280,7 @@ class QueueItem(object):
def __init__(self, queue, change):
self.pipeline = queue.pipeline
self.queue = queue
self.change = change # a changeish
self.change = change # a ref
self.build_sets = []
self.dequeued_needing_change = False
self.current_build_set = BuildSet(self)
@ -1589,15 +1589,14 @@ class QueueItem(object):
return (result, url)
def formatJSON(self):
changeish = self.change
ret = {}
ret['active'] = self.active
ret['live'] = self.live
if hasattr(changeish, 'url') and changeish.url is not None:
ret['url'] = changeish.url
if hasattr(self.change, 'url') and self.change.url is not None:
ret['url'] = self.change.url
else:
ret['url'] = None
ret['id'] = changeish._id()
ret['id'] = self.change._id()
if self.item_ahead:
ret['item_ahead'] = self.item_ahead.change._id()
else:
@ -1605,8 +1604,8 @@ class QueueItem(object):
ret['items_behind'] = [i.change._id() for i in self.items_behind]
ret['failing_reasons'] = self.current_build_set.failing_reasons
ret['zuul_ref'] = self.current_build_set.ref
if changeish.project:
ret['project'] = changeish.project.name
if self.change.project:
ret['project'] = self.change.project.name
else:
# For cross-project dependencies with the depends-on
# project not known to zuul, the project is None
@ -1614,8 +1613,8 @@ class QueueItem(object):
ret['project'] = "Unknown Project"
ret['enqueue_time'] = int(self.enqueue_time * 1000)
ret['jobs'] = []
if hasattr(changeish, 'owner'):
ret['owner'] = changeish.owner
if hasattr(self.change, 'owner'):
ret['owner'] = self.change.owner
else:
ret['owner'] = None
max_remaining = 0
@ -1683,20 +1682,19 @@ class QueueItem(object):
return ret
def formatStatus(self, indent=0, html=False):
changeish = self.change
indent_str = ' ' * indent
ret = ''
if html and hasattr(changeish, 'url') and changeish.url is not None:
if html and getattr(self.change, 'url', None) is not None:
ret += '%sProject %s change <a href="%s">%s</a>\n' % (
indent_str,
changeish.project.name,
changeish.url,
changeish._id())
self.change.project.name,
self.change.url,
self.change._id())
else:
ret += '%sProject %s change %s based on %s\n' % (
indent_str,
changeish.project.name,
changeish._id(),
self.change.project.name,
self.change._id(),
self.item_ahead)
for job in self.getJobs():
build = self.current_build_set.getBuild(job.name)

Loading…
Cancel
Save