From 4daa065dc9ae3e10cb17940239bde21f4be3f71d Mon Sep 17 00:00:00 2001 From: Anish Athalye Date: Sun, 9 Jul 2023 15:20:42 -0400 Subject: [PATCH] Allow empty glob This is convenient and more flexible. See https://github.com/anishathalye/dotbot/issues/284. --- dotbot/plugins/link.py | 3 +-- tests/test_link.py | 13 +++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/dotbot/plugins/link.py b/dotbot/plugins/link.py index d0f8634..6799cc1 100644 --- a/dotbot/plugins/link.py +++ b/dotbot/plugins/link.py @@ -62,8 +62,7 @@ class Link(Plugin): if use_glob: glob_results = self._create_glob_results(path, exclude_paths) if len(glob_results) == 0: - self._log.warning("Globbing couldn't find anything matching " + str(path)) - success = False + self._log.lowinfo("Globbing couldn't find anything matching " + str(path)) continue if len(glob_results) == 1 and destination[-1] == "/": self._log.error("Ambiguous action requested.") diff --git a/tests/test_link.py b/tests/test_link.py index dd6d085..86bc7c9 100644 --- a/tests/test_link.py +++ b/tests/test_link.py @@ -587,6 +587,19 @@ def test_link_glob_recursive(home, dotfiles, run_dotbot): assert file.read() == "cherry" +def test_link_glob_no_match(home, dotfiles, run_dotbot): + """Verify that a glob with no match doesn't raise an error.""" + + dotfiles.makedirs("foo") + dotfiles.write_config( + [ + {"defaults": {"link": {"glob": True, "create": True}}}, + {"link": {"~/.config/foo": "foo/*"}}, + ] + ) + run_dotbot() + + @pytest.mark.skipif( "sys.platform[:5] == 'win32'", reason="These if commands won't run on Windows",