mirror of
1
0
Fork 0

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:
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.")

View File

@ -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",