From 81f0d7495518a1fe441343024f2320c95eff86b4 Mon Sep 17 00:00:00 2001 From: Anish Athalye Date: Tue, 31 Dec 2019 14:47:32 -0500 Subject: 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 item. The other plugins (link, shell) do not have this problem. --- dotbot/plugins/clean.py | 4 ++-- test/tests/clean-default.bash | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 test/tests/clean-default.bash diff --git a/dotbot/plugins/clean.py b/dotbot/plugins/clean.py index 22c975e..89251b9 100644 --- a/dotbot/plugins/clean.py +++ b/dotbot/plugins/clean.py @@ -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: diff --git a/test/tests/clean-default.bash b/test/tests/clean-default.bash new file mode 100644 index 0000000..8bb405d --- /dev/null +++ b/test/tests/clean-default.bash @@ -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 <