Skip to content

Commit

Permalink
Don't try to parse host sets in get_relevant_files()
Browse files Browse the repository at this point in the history
This is taken care of in the parse_config(), so no need to do this again.
  • Loading branch information
winpat committed Feb 14, 2024
1 parent 01c3a38 commit c56236b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
6 changes: 3 additions & 3 deletions dotm/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
def get_relevant_files(config: Dict) -> List[str]:
"""Collect relevant files for host."""
hostname = gethostname()
relevant: List[str] = []

for host_set, files in config.items():
if hostname in host_set.split("|") or host_set == "all":
relevant: List[str] = []
for host, files in config.items():
if host == hostname or host == "all":
relevant.extend(files)

return relevant
Expand Down
4 changes: 1 addition & 3 deletions dotm/main_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@
@pytest.mark.parametrize(
"config,file_paths,hostname",
[
# Straight forward with "all" block
(
{"all": [".emacs"], "host1": [".tmux.conf"], "otherhost": [".vimrc"]},
{".emacs", ".tmux.conf"},
"host1",
),
# Multi host block
({"host1|host2|host3": [".emacs"]}, {".emacs"}, "host1"),
({"host1": [".emacs"]}, {".emacs"}, "host1"),
],
)
def test_relevant_files(mocker, config, file_paths, hostname):
Expand Down

0 comments on commit c56236b

Please sign in to comment.