Quellcode durchsuchen

Allow the "--repository" flag to match across multiple configuration files (#818).

Dan Helfman vor 1 Jahr
Ursprung
Commit
e9813d2539
4 geänderte Dateien mit 7 neuen und 22 gelöschten Zeilen
  1. 3 0
      NEWS
  2. 3 6
      borgmatic/config/validate.py
  3. 1 1
      setup.py
  4. 0 15
      tests/unit/config/test_validate.py

+ 3 - 0
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.

+ 3 - 6
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):

+ 1 - 1
setup.py

@@ -1,6 +1,6 @@
 from setuptools import find_packages, setup
 
-VERSION = '1.8.7'
+VERSION = '1.8.8.dev0'
 
 
 setup(

+ 0 - 15
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(