only do squash when 'squashable field' present

This commit is contained in:
Brian Coca 2016-03-01 15:11:04 -05:00
parent 18240d350c
commit 71402abf21

View file

@ -279,29 +279,30 @@ class TaskExecutor:
# This gets the information to check whether the name field # This gets the information to check whether the name field
# contains a template that we can squash for # contains a template that we can squash for
template_no_item = template_with_item = None template_no_item = template_with_item = None
if templar._contains_vars(name): if name:
variables['item'] = '\0$' if templar._contains_vars(name):
template_no_item = templar.template(name, variables, cache=False) variables['item'] = '\0$'
variables['item'] = '\0@' template_no_item = templar.template(name, variables, cache=False)
template_with_item = templar.template(name, variables, cache=False) variables['item'] = '\0@'
del variables['item'] template_with_item = templar.template(name, variables, cache=False)
del variables['item']
# Check if the user is doing some operation that doesn't take # Check if the user is doing some operation that doesn't take
# name/pkg or the name/pkg field doesn't have any variables # name/pkg or the name/pkg field doesn't have any variables
# and thus the items can't be squashed # and thus the items can't be squashed
if name and (template_no_item != template_with_item): if template_no_item != template_with_item:
for item in items: for item in items:
variables['item'] = item variables['item'] = item
if self._task.evaluate_conditional(templar, variables): if self._task.evaluate_conditional(templar, variables):
new_item = templar.template(name, cache=False) new_item = templar.template(name, cache=False)
final_items.append(new_item) final_items.append(new_item)
self._task.args['name'] = final_items self._task.args['name'] = final_items
# Wrap this in a list so that the calling function loop # Wrap this in a list so that the calling function loop
# executes exactly once # executes exactly once
return [final_items] return [final_items]
else: else:
# Restore the name parameter # Restore the name parameter
self._task.args['name'] = name self._task.args['name'] = name
#elif: #elif:
# Right now we only optimize single entries. In the future we # Right now we only optimize single entries. In the future we
# could optimize more types: # could optimize more types: