1
0
Fork 0
mirror of synced 2024-11-03 00:48:57 -04:00

Allow empty glob

This is convenient and more flexible. See
https://github.com/anishathalye/dotbot/issues/284.
This commit is contained in:
Anish Athalye 2023-07-09 15:20:42 -04:00
parent ed60c62432
commit 4daa065dc9
2 changed files with 14 additions and 2 deletions

View file

@ -62,8 +62,7 @@ class Link(Plugin):
if use_glob: if use_glob:
glob_results = self._create_glob_results(path, exclude_paths) glob_results = self._create_glob_results(path, exclude_paths)
if len(glob_results) == 0: if len(glob_results) == 0:
self._log.warning("Globbing couldn't find anything matching " + str(path)) self._log.lowinfo("Globbing couldn't find anything matching " + str(path))
success = False
continue continue
if len(glob_results) == 1 and destination[-1] == "/": if len(glob_results) == 1 and destination[-1] == "/":
self._log.error("Ambiguous action requested.") self._log.error("Ambiguous action requested.")

View file

@ -587,6 +587,19 @@ def test_link_glob_recursive(home, dotfiles, run_dotbot):
assert file.read() == "cherry" 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( @pytest.mark.skipif(
"sys.platform[:5] == 'win32'", "sys.platform[:5] == 'win32'",
reason="These if commands won't run on Windows", reason="These if commands won't run on Windows",