diff --git a/NEWS b/NEWS index ef7758ae..92661103 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,6 @@ +1.8.8.dev0 + * #818: Allow the "--repository" flag to match across multiple configuration files. + 1.8.7 * #736: Store included configuration files within each backup archive in support of the "config bootstrap" action. Previously, only top-level configuration files were stored. diff --git a/borgmatic/config/validate.py b/borgmatic/config/validate.py index 3ac205e8..bf9869be 100644 --- a/borgmatic/config/validate.py +++ b/borgmatic/config/validate.py @@ -167,11 +167,10 @@ def repositories_match(first, second): def guard_configuration_contains_repository(repository, configurations): ''' Given a repository path and a dict mapping from config filename to corresponding parsed config - dict, ensure that the repository is declared exactly once in all of the configurations. If no + dict, ensure that the repository is declared at least once in all of the configurations. If no repository is given, skip this check. - Raise ValueError if the repository is not found in a configuration, or is declared multiple - times. + Raise ValueError if the repository is not found in any configurations. ''' if not repository: return @@ -186,9 +185,7 @@ def guard_configuration_contains_repository(repository, configurations): ) if count == 0: - raise ValueError(f'Repository {repository} not found in configuration files') - if count > 1: - raise ValueError(f'Repository {repository} found in multiple configuration files') + raise ValueError(f'Repository "{repository}" not found in configuration files') def guard_single_repository_selected(repository, configurations): diff --git a/setup.py b/setup.py index b7d5b290..dd98bc5f 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ from setuptools import find_packages, setup -VERSION = '1.8.7' +VERSION = '1.8.8.dev0' setup( diff --git a/tests/unit/config/test_validate.py b/tests/unit/config/test_validate.py index 182cbd17..93305158 100644 --- a/tests/unit/config/test_validate.py +++ b/tests/unit/config/test_validate.py @@ -184,21 +184,6 @@ def test_guard_configuration_contains_repository_errors_when_repository_missing_ ) -def test_guard_configuration_contains_repository_errors_when_repository_matches_config_twice(): - flexmock(module).should_receive('repositories_match').replace_with( - lambda first, second: first == second - ) - - with pytest.raises(ValueError): - module.guard_configuration_contains_repository( - repository='repo', - configurations={ - 'config.yaml': {'repositories': ['repo', 'repo2']}, - 'other.yaml': {'repositories': ['repo']}, - }, - ) - - def test_guard_single_repository_selected_raises_when_multiple_repositories_configured_and_none_selected(): with pytest.raises(ValueError): module.guard_single_repository_selected(