From cf366bbf6676d1c95f412eb514509f16322b5c9c Mon Sep 17 00:00:00 2001 From: Anish Athalye Date: Sun, 22 Nov 2020 16:58:00 -0500 Subject: [PATCH] Fix interaction between --only and defaults We should treat defaults specially, and even when `--only` is specified, we should always run defaults. --- dotbot/dispatcher.py | 5 +++-- test/Vagrantfile | 1 - test/tests/only-defaults.bash | 21 +++++++++++++++++++++ 3 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 test/tests/only-defaults.bash diff --git a/dotbot/dispatcher.py b/dotbot/dispatcher.py index 10e4293..646f6a0 100644 --- a/dotbot/dispatcher.py +++ b/dotbot/dispatcher.py @@ -22,8 +22,9 @@ class Dispatcher(object): success = True for task in tasks: for action in task: - if self._only is not None and action not in self._only \ - or self._skip is not None and action in self._skip: + if (self._only is not None and action not in self._only \ + or self._skip is not None and action in self._skip) \ + and action != 'defaults': self._log.info('Skipping action %s' % action) continue handled = False diff --git a/test/Vagrantfile b/test/Vagrantfile index fbdfe39..a6442f9 100644 --- a/test/Vagrantfile +++ b/test/Vagrantfile @@ -1,7 +1,6 @@ Vagrant.configure(2) do |config| config.vm.box = 'ubuntu/bionic64' - # sync by copying for isolation config.vm.synced_folder "..", "/dotbot", mount_options: ["ro"] # disable default synced folder diff --git a/test/tests/only-defaults.bash b/test/tests/only-defaults.bash new file mode 100644 index 0000000..4ef133a --- /dev/null +++ b/test/tests/only-defaults.bash @@ -0,0 +1,21 @@ +test_description='--only does not skip defaults' +. '../test-lib.bash' + +test_expect_success 'setup' ' +echo "apple" > ${DOTFILES}/x +' + +test_expect_success 'run' ' +run_dotbot --only link < ~/z +- link: + ~/d/x: x +' + +test_expect_success 'test' ' +grep "apple" ~/d/x && ! test -f ~/z +'