mirror of
Fork 0

Fix clean not respecting defaults

Previously, clean read the defaults once, and then it updated the
setting for each entry it read. This resulted in the defaults being
clobbered and then not being respected for subsequent entries. This
patch fixes the issue by re-reading the defaults before processing each

The other plugins (link, shell) do not have this problem.
This commit is contained in:
Anish Athalye 2019-12-31 14:47:32 -05:00
parent a7bfce3e23
commit 81f0d74955
2 changed files with 21 additions and 2 deletions

View File

@ -18,9 +18,9 @@ class Clean(dotbot.Plugin):
def _process_clean(self, targets):
success = True
defaults = self._context.defaults().get(self._directive, {})
force = defaults.get('force', False)
for target in targets:
if isinstance(targets, dict):
force = defaults.get('force', False)
if isinstance(targets, dict) and isinstance(targets[target], dict):
force = targets[target].get('force', force)
success &= self._clean(target, force)
if success:

View File

@ -0,0 +1,19 @@
test_description='clean uses default unless overridden'
. '../test-lib.bash'
test_expect_success 'setup' '
ln -s /nowhere ~/.g
test_expect_success 'run' '
run_dotbot <<EOF
- clean:
force: true
test_expect_success 'test' '
test -h ~/.g