only do squash when 'squashable field' present

pull/14740/head
Brian Coca 10 years ago
parent 18240d350c
commit 71402abf21

@ -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
# name/pkg or the name/pkg field doesn't have any variables # Check if the user is doing some operation that doesn't take
# and thus the items can't be squashed # name/pkg or the name/pkg field doesn't have any variables
if name and (template_no_item != template_with_item): # and thus the items can't be squashed
for item in items: if template_no_item != template_with_item:
variables['item'] = item for item in items:
if self._task.evaluate_conditional(templar, variables): variables['item'] = item
new_item = templar.template(name, cache=False) if self._task.evaluate_conditional(templar, variables):
final_items.append(new_item) new_item = templar.template(name, cache=False)
self._task.args['name'] = final_items final_items.append(new_item)
# Wrap this in a list so that the calling function loop self._task.args['name'] = final_items
# executes exactly once # Wrap this in a list so that the calling function loop
return [final_items] # executes exactly once
else: return [final_items]
# Restore the name parameter else:
self._task.args['name'] = name # Restore the name parameter
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:

Loading…
Cancel
Save