Browse Source

Fix the "--repository" flag not applying to command hooks (#1176).

Dan Helfman 5 days ago
parent
commit
3d15c51039
46 changed files with 362 additions and 747 deletions
  1. 1 0
      NEWS
  2. 19 24
      borgmatic/actions/borg.py
  3. 9 14
      borgmatic/actions/break_lock.py
  4. 10 18
      borgmatic/actions/change_passphrase.py
  5. 0 7
      borgmatic/actions/check.py
  6. 0 7
      borgmatic/actions/compact.py
  7. 0 1
      borgmatic/actions/config/bootstrap.py
  8. 0 7
      borgmatic/actions/create.py
  9. 18 22
      borgmatic/actions/delete.py
  10. 10 15
      borgmatic/actions/export_key.py
  11. 19 24
      borgmatic/actions/export_tar.py
  12. 18 23
      borgmatic/actions/extract.py
  13. 10 15
      borgmatic/actions/import_key.py
  14. 22 27
      borgmatic/actions/info.py
  15. 25 30
      borgmatic/actions/list.py
  16. 18 23
      borgmatic/actions/mount.py
  17. 0 7
      borgmatic/actions/prune.py
  18. 45 50
      borgmatic/actions/recreate.py
  19. 0 7
      borgmatic/actions/repo_create.py
  20. 12 16
      borgmatic/actions/repo_delete.py
  21. 13 18
      borgmatic/actions/repo_info.py
  22. 13 18
      borgmatic/actions/repo_list.py
  23. 1 9
      borgmatic/actions/restore.py
  24. 17 1
      borgmatic/commands/borgmatic.py
  25. 0 1
      tests/unit/actions/test_borg.py
  26. 0 1
      tests/unit/actions/test_break_lock.py
  27. 0 1
      tests/unit/actions/test_change_passphrase.py
  28. 0 69
      tests/unit/actions/test_check.py
  29. 0 57
      tests/unit/actions/test_compact.py
  30. 0 88
      tests/unit/actions/test_create.py
  31. 0 2
      tests/unit/actions/test_delete.py
  32. 0 1
      tests/unit/actions/test_export_key.py
  33. 0 3
      tests/unit/actions/test_export_tar.py
  34. 0 3
      tests/unit/actions/test_extract.py
  35. 0 1
      tests/unit/actions/test_import_key.py
  36. 0 2
      tests/unit/actions/test_info.py
  37. 0 2
      tests/unit/actions/test_list.py
  38. 0 1
      tests/unit/actions/test_mount.py
  39. 0 53
      tests/unit/actions/test_prune.py
  40. 0 7
      tests/unit/actions/test_recreate.py
  41. 0 32
      tests/unit/actions/test_repo_create.py
  42. 0 2
      tests/unit/actions/test_repo_delete.py
  43. 0 2
      tests/unit/actions/test_repo_info.py
  44. 0 2
      tests/unit/actions/test_repo_list.py
  45. 0 34
      tests/unit/actions/test_restore.py
  46. 82 0
      tests/unit/commands/test_borgmatic.py

+ 1 - 0
NEWS

@@ -10,6 +10,7 @@
    snapshot paths were ignored.
  * #1170: Fix for an inconsistent log level for Borg's last output line before exiting.
  * #1172: Add an "environment" option to the Sentry monitoring hook.
+ * #1176: Fix the "--repository" flag not applying to command hooks.
  * Add a "rename" option to "extra_borg_options" to support passing arbitrary flags to "borg
    rename".
  * Add documentation on patterns and excludes:

+ 19 - 24
borgmatic/actions/borg.py

@@ -2,7 +2,6 @@ import logging
 
 import borgmatic.borg.borg
 import borgmatic.borg.repo_list
-import borgmatic.config.validate
 
 logger = logging.getLogger(__name__)
 
@@ -19,26 +18,22 @@ def run_borg(
     '''
     Run the "borg" action for the given repository.
     '''
-    if borg_arguments.repository is None or borgmatic.config.validate.repositories_match(
-        repository,
-        borg_arguments.repository,
-    ):
-        logger.info('Running arbitrary Borg command')
-        archive_name = borgmatic.borg.repo_list.resolve_archive_name(
-            repository['path'],
-            borg_arguments.archive,
-            config,
-            local_borg_version,
-            global_arguments,
-            local_path,
-            remote_path,
-        )
-        borgmatic.borg.borg.run_arbitrary_borg(
-            repository['path'],
-            config,
-            local_borg_version,
-            options=borg_arguments.options,
-            archive=archive_name,
-            local_path=local_path,
-            remote_path=remote_path,
-        )
+    logger.info('Running arbitrary Borg command')
+    archive_name = borgmatic.borg.repo_list.resolve_archive_name(
+        repository['path'],
+        borg_arguments.archive,
+        config,
+        local_borg_version,
+        global_arguments,
+        local_path,
+        remote_path,
+    )
+    borgmatic.borg.borg.run_arbitrary_borg(
+        repository['path'],
+        config,
+        local_borg_version,
+        options=borg_arguments.options,
+        archive=archive_name,
+        local_path=local_path,
+        remote_path=remote_path,
+    )

+ 9 - 14
borgmatic/actions/break_lock.py

@@ -1,7 +1,6 @@
 import logging
 
 import borgmatic.borg.break_lock
-import borgmatic.config.validate
 
 logger = logging.getLogger(__name__)
 
@@ -18,16 +17,12 @@ def run_break_lock(
     '''
     Run the "break-lock" action for the given repository.
     '''
-    if break_lock_arguments.repository is None or borgmatic.config.validate.repositories_match(
-        repository,
-        break_lock_arguments.repository,
-    ):
-        logger.info('Breaking repository and cache locks')
-        borgmatic.borg.break_lock.break_lock(
-            repository['path'],
-            config,
-            local_borg_version,
-            global_arguments,
-            local_path=local_path,
-            remote_path=remote_path,
-        )
+    logger.info('Breaking repository and cache locks')
+    borgmatic.borg.break_lock.break_lock(
+        repository['path'],
+        config,
+        local_borg_version,
+        global_arguments,
+        local_path=local_path,
+        remote_path=remote_path,
+    )

+ 10 - 18
borgmatic/actions/change_passphrase.py

@@ -1,7 +1,6 @@
 import logging
 
 import borgmatic.borg.change_passphrase
-import borgmatic.config.validate
 
 logger = logging.getLogger(__name__)
 
@@ -18,20 +17,13 @@ def run_change_passphrase(
     '''
     Run the "key change-passphrase" action for the given repository.
     '''
-    if (
-        change_passphrase_arguments.repository is None
-        or borgmatic.config.validate.repositories_match(
-            repository,
-            change_passphrase_arguments.repository,
-        )
-    ):
-        logger.info('Changing repository passphrase')
-        borgmatic.borg.change_passphrase.change_passphrase(
-            repository['path'],
-            config,
-            local_borg_version,
-            change_passphrase_arguments,
-            global_arguments,
-            local_path=local_path,
-            remote_path=remote_path,
-        )
+    logger.info('Changing repository passphrase')
+    borgmatic.borg.change_passphrase.change_passphrase(
+        repository['path'],
+        config,
+        local_borg_version,
+        change_passphrase_arguments,
+        global_arguments,
+        local_path=local_path,
+        remote_path=remote_path,
+    )

+ 0 - 7
borgmatic/actions/check.py

@@ -22,7 +22,6 @@ import borgmatic.borg.pattern
 import borgmatic.borg.repo_list
 import borgmatic.borg.state
 import borgmatic.config.paths
-import borgmatic.config.validate
 import borgmatic.execute
 import borgmatic.hooks.command
 
@@ -750,12 +749,6 @@ def run_check(
 
     Raise ValueError if the Borg repository ID cannot be determined.
     '''
-    if check_arguments.repository and not borgmatic.config.validate.repositories_match(
-        repository,
-        check_arguments.repository,
-    ):
-        return
-
     logger.info('Running consistency checks')
 
     repository_id = borgmatic.borg.check.get_repository_id(

+ 0 - 7
borgmatic/actions/compact.py

@@ -2,7 +2,6 @@ import logging
 
 import borgmatic.borg.compact
 import borgmatic.borg.feature
-import borgmatic.config.validate
 import borgmatic.hooks.command
 
 logger = logging.getLogger(__name__)
@@ -22,12 +21,6 @@ def run_compact(
     '''
     Run the "compact" action for the given repository.
     '''
-    if compact_arguments.repository and not borgmatic.config.validate.repositories_match(
-        repository,
-        compact_arguments.repository,
-    ):
-        return
-
     if borgmatic.borg.feature.available(borgmatic.borg.feature.Feature.COMPACT, local_borg_version):
         logger.info(f'Compacting segments{dry_run_label}')
         borgmatic.borg.compact.compact_segments(

+ 0 - 1
borgmatic/actions/config/bootstrap.py

@@ -5,7 +5,6 @@ import os
 import borgmatic.borg.extract
 import borgmatic.borg.repo_list
 import borgmatic.config.paths
-import borgmatic.config.validate
 import borgmatic.hooks.command
 
 logger = logging.getLogger(__name__)

+ 0 - 7
borgmatic/actions/create.py

@@ -6,7 +6,6 @@ import borgmatic.borg.feature
 import borgmatic.borg.rename
 import borgmatic.borg.repo_list
 import borgmatic.config.paths
-import borgmatic.config.validate
 import borgmatic.hooks.dispatch
 from borgmatic.actions import pattern
 
@@ -30,12 +29,6 @@ def run_create(
 
     If create_arguments.json is True, yield the JSON output from creating the archive.
     '''
-    if create_arguments.repository and not borgmatic.config.validate.repositories_match(
-        repository,
-        create_arguments.repository,
-    ):
-        return
-
     if config.get('list_details') and config.get('progress'):
         raise ValueError(
             'With the create action, only one of --list/--files/list_details and --progress/progress can be used.',

+ 18 - 22
borgmatic/actions/delete.py

@@ -20,32 +20,28 @@ def run_delete(
     '''
     Run the "delete" action for the given repository and archive(s).
     '''
-    if delete_arguments.repository is None or borgmatic.config.validate.repositories_match(
-        repository,
-        delete_arguments.repository,
-    ):
-        logger.answer('Deleting archives')
-
-        archive_name = (
-            borgmatic.borg.repo_list.resolve_archive_name(
-                repository['path'],
-                delete_arguments.archive,
-                config,
-                local_borg_version,
-                global_arguments,
-                local_path,
-                remote_path,
-            )
-            if delete_arguments.archive
-            else None
-        )
+    logger.answer('Deleting archives')
 
-        borgmatic.borg.delete.delete_archives(
-            repository,
+    archive_name = (
+        borgmatic.borg.repo_list.resolve_archive_name(
+            repository['path'],
+            delete_arguments.archive,
             config,
             local_borg_version,
-            borgmatic.actions.arguments.update_arguments(delete_arguments, archive=archive_name),
             global_arguments,
             local_path,
             remote_path,
         )
+        if delete_arguments.archive
+        else None
+    )
+
+    borgmatic.borg.delete.delete_archives(
+        repository,
+        config,
+        local_borg_version,
+        borgmatic.actions.arguments.update_arguments(delete_arguments, archive=archive_name),
+        global_arguments,
+        local_path,
+        remote_path,
+    )

+ 10 - 15
borgmatic/actions/export_key.py

@@ -1,7 +1,6 @@
 import logging
 
 import borgmatic.borg.export_key
-import borgmatic.config.validate
 
 logger = logging.getLogger(__name__)
 
@@ -18,17 +17,13 @@ def run_export_key(
     '''
     Run the "key export" action for the given repository.
     '''
-    if export_arguments.repository is None or borgmatic.config.validate.repositories_match(
-        repository,
-        export_arguments.repository,
-    ):
-        logger.info('Exporting repository key')
-        borgmatic.borg.export_key.export_key(
-            repository['path'],
-            config,
-            local_borg_version,
-            export_arguments,
-            global_arguments,
-            local_path=local_path,
-            remote_path=remote_path,
-        )
+    logger.info('Exporting repository key')
+    borgmatic.borg.export_key.export_key(
+        repository['path'],
+        config,
+        local_borg_version,
+        export_arguments,
+        global_arguments,
+        local_path=local_path,
+        remote_path=remote_path,
+    )

+ 19 - 24
borgmatic/actions/export_tar.py

@@ -2,7 +2,6 @@ import logging
 
 import borgmatic.borg.export_tar
 import borgmatic.borg.repo_list
-import borgmatic.config.validate
 
 logger = logging.getLogger(__name__)
 
@@ -19,30 +18,26 @@ def run_export_tar(
     '''
     Run the "export-tar" action for the given repository.
     '''
-    if export_tar_arguments.repository is None or borgmatic.config.validate.repositories_match(
-        repository,
-        export_tar_arguments.repository,
-    ):
-        logger.info(f'Exporting archive {export_tar_arguments.archive} as tar file')
-        borgmatic.borg.export_tar.export_tar_archive(
-            global_arguments.dry_run,
+    logger.info(f'Exporting archive {export_tar_arguments.archive} as tar file')
+    borgmatic.borg.export_tar.export_tar_archive(
+        global_arguments.dry_run,
+        repository['path'],
+        borgmatic.borg.repo_list.resolve_archive_name(
             repository['path'],
-            borgmatic.borg.repo_list.resolve_archive_name(
-                repository['path'],
-                export_tar_arguments.archive,
-                config,
-                local_borg_version,
-                global_arguments,
-                local_path,
-                remote_path,
-            ),
-            export_tar_arguments.paths,
-            export_tar_arguments.destination,
+            export_tar_arguments.archive,
             config,
             local_borg_version,
             global_arguments,
-            local_path=local_path,
-            remote_path=remote_path,
-            tar_filter=export_tar_arguments.tar_filter,
-            strip_components=export_tar_arguments.strip_components,
-        )
+            local_path,
+            remote_path,
+        ),
+        export_tar_arguments.paths,
+        export_tar_arguments.destination,
+        config,
+        local_borg_version,
+        global_arguments,
+        local_path=local_path,
+        remote_path=remote_path,
+        tar_filter=export_tar_arguments.tar_filter,
+        strip_components=export_tar_arguments.strip_components,
+    )

+ 18 - 23
borgmatic/actions/extract.py

@@ -2,7 +2,6 @@ import logging
 
 import borgmatic.borg.extract
 import borgmatic.borg.repo_list
-import borgmatic.config.validate
 import borgmatic.hooks.command
 
 logger = logging.getLogger(__name__)
@@ -21,29 +20,25 @@ def run_extract(
     '''
     Run the "extract" action for the given repository.
     '''
-    if extract_arguments.repository is None or borgmatic.config.validate.repositories_match(
-        repository,
-        extract_arguments.repository,
-    ):
-        logger.info(f'Extracting archive {extract_arguments.archive}')
-        borgmatic.borg.extract.extract_archive(
-            global_arguments.dry_run,
+    logger.info(f'Extracting archive {extract_arguments.archive}')
+    borgmatic.borg.extract.extract_archive(
+        global_arguments.dry_run,
+        repository['path'],
+        borgmatic.borg.repo_list.resolve_archive_name(
             repository['path'],
-            borgmatic.borg.repo_list.resolve_archive_name(
-                repository['path'],
-                extract_arguments.archive,
-                config,
-                local_borg_version,
-                global_arguments,
-                local_path,
-                remote_path,
-            ),
-            extract_arguments.paths,
+            extract_arguments.archive,
             config,
             local_borg_version,
             global_arguments,
-            local_path=local_path,
-            remote_path=remote_path,
-            destination_path=extract_arguments.destination,
-            strip_components=extract_arguments.strip_components,
-        )
+            local_path,
+            remote_path,
+        ),
+        extract_arguments.paths,
+        config,
+        local_borg_version,
+        global_arguments,
+        local_path=local_path,
+        remote_path=remote_path,
+        destination_path=extract_arguments.destination,
+        strip_components=extract_arguments.strip_components,
+    )

+ 10 - 15
borgmatic/actions/import_key.py

@@ -1,7 +1,6 @@
 import logging
 
 import borgmatic.borg.import_key
-import borgmatic.config.validate
 
 logger = logging.getLogger(__name__)
 
@@ -18,17 +17,13 @@ def run_import_key(
     '''
     Run the "key import" action for the given repository.
     '''
-    if import_arguments.repository is None or borgmatic.config.validate.repositories_match(
-        repository,
-        import_arguments.repository,
-    ):
-        logger.info('Importing repository key')
-        borgmatic.borg.import_key.import_key(
-            repository['path'],
-            config,
-            local_borg_version,
-            import_arguments,
-            global_arguments,
-            local_path=local_path,
-            remote_path=remote_path,
-        )
+    logger.info('Importing repository key')
+    borgmatic.borg.import_key.import_key(
+        repository['path'],
+        config,
+        local_borg_version,
+        import_arguments,
+        global_arguments,
+        local_path=local_path,
+        remote_path=remote_path,
+    )

+ 22 - 27
borgmatic/actions/info.py

@@ -4,7 +4,6 @@ import borgmatic.actions.arguments
 import borgmatic.actions.json
 import borgmatic.borg.info
 import borgmatic.borg.repo_list
-import borgmatic.config.validate
 
 logger = logging.getLogger(__name__)
 
@@ -23,30 +22,26 @@ def run_info(
 
     If info_arguments.json is True, yield the JSON output from the info for the archive.
     '''
-    if info_arguments.repository is None or borgmatic.config.validate.repositories_match(
-        repository,
-        info_arguments.repository,
-    ):
-        if not info_arguments.json:
-            logger.answer('Displaying archive summary information')
+    if not info_arguments.json:
+        logger.answer('Displaying archive summary information')
 
-        archive_name = borgmatic.borg.repo_list.resolve_archive_name(
-            repository['path'],
-            info_arguments.archive,
-            config,
-            local_borg_version,
-            global_arguments,
-            local_path,
-            remote_path,
-        )
-        json_output = borgmatic.borg.info.display_archives_info(
-            repository['path'],
-            config,
-            local_borg_version,
-            borgmatic.actions.arguments.update_arguments(info_arguments, archive=archive_name),
-            global_arguments,
-            local_path,
-            remote_path,
-        )
-        if json_output:
-            yield borgmatic.actions.json.parse_json(json_output, repository.get('label'))
+    archive_name = borgmatic.borg.repo_list.resolve_archive_name(
+        repository['path'],
+        info_arguments.archive,
+        config,
+        local_borg_version,
+        global_arguments,
+        local_path,
+        remote_path,
+    )
+    json_output = borgmatic.borg.info.display_archives_info(
+        repository['path'],
+        config,
+        local_borg_version,
+        borgmatic.actions.arguments.update_arguments(info_arguments, archive=archive_name),
+        global_arguments,
+        local_path,
+        remote_path,
+    )
+    if json_output:
+        yield borgmatic.actions.json.parse_json(json_output, repository.get('label'))

+ 25 - 30
borgmatic/actions/list.py

@@ -3,7 +3,6 @@ import logging
 import borgmatic.actions.arguments
 import borgmatic.actions.json
 import borgmatic.borg.list
-import borgmatic.config.validate
 
 logger = logging.getLogger(__name__)
 
@@ -22,33 +21,29 @@ def run_list(
 
     If list_arguments.json is True, yield the JSON output from listing the archive.
     '''
-    if list_arguments.repository is None or borgmatic.config.validate.repositories_match(
-        repository,
-        list_arguments.repository,
-    ):
-        if not list_arguments.json:
-            if list_arguments.find_paths:  # pragma: no cover
-                logger.answer('Searching archives')
-            elif not list_arguments.archive:  # pragma: no cover
-                logger.answer('Listing archives')
+    if not list_arguments.json:
+        if list_arguments.find_paths:  # pragma: no cover
+            logger.answer('Searching archives')
+        elif not list_arguments.archive:  # pragma: no cover
+            logger.answer('Listing archives')
 
-        archive_name = borgmatic.borg.repo_list.resolve_archive_name(
-            repository['path'],
-            list_arguments.archive,
-            config,
-            local_borg_version,
-            global_arguments,
-            local_path,
-            remote_path,
-        )
-        json_output = borgmatic.borg.list.list_archive(
-            repository['path'],
-            config,
-            local_borg_version,
-            borgmatic.actions.arguments.update_arguments(list_arguments, archive=archive_name),
-            global_arguments,
-            local_path,
-            remote_path,
-        )
-        if json_output:
-            yield borgmatic.actions.json.parse_json(json_output, repository.get('label'))
+    archive_name = borgmatic.borg.repo_list.resolve_archive_name(
+        repository['path'],
+        list_arguments.archive,
+        config,
+        local_borg_version,
+        global_arguments,
+        local_path,
+        remote_path,
+    )
+    json_output = borgmatic.borg.list.list_archive(
+        repository['path'],
+        config,
+        local_borg_version,
+        borgmatic.actions.arguments.update_arguments(list_arguments, archive=archive_name),
+        global_arguments,
+        local_path,
+        remote_path,
+    )
+    if json_output:
+        yield borgmatic.actions.json.parse_json(json_output, repository.get('label'))

+ 18 - 23
borgmatic/actions/mount.py

@@ -2,7 +2,6 @@ import logging
 
 import borgmatic.borg.mount
 import borgmatic.borg.repo_list
-import borgmatic.config.validate
 
 logger = logging.getLogger(__name__)
 
@@ -19,30 +18,26 @@ def run_mount(
     '''
     Run the "mount" action for the given repository.
     '''
-    if mount_arguments.repository is None or borgmatic.config.validate.repositories_match(
-        repository,
-        mount_arguments.repository,
-    ):
-        if mount_arguments.archive:
-            logger.info(f'Mounting archive {mount_arguments.archive}')
-        else:  # pragma: nocover
-            logger.info('Mounting repository')
+    if mount_arguments.archive:
+        logger.info(f'Mounting archive {mount_arguments.archive}')
+    else:  # pragma: nocover
+        logger.info('Mounting repository')
 
-        borgmatic.borg.mount.mount_archive(
+    borgmatic.borg.mount.mount_archive(
+        repository['path'],
+        borgmatic.borg.repo_list.resolve_archive_name(
             repository['path'],
-            borgmatic.borg.repo_list.resolve_archive_name(
-                repository['path'],
-                mount_arguments.archive,
-                config,
-                local_borg_version,
-                global_arguments,
-                local_path,
-                remote_path,
-            ),
-            mount_arguments,
+            mount_arguments.archive,
             config,
             local_borg_version,
             global_arguments,
-            local_path=local_path,
-            remote_path=remote_path,
-        )
+            local_path,
+            remote_path,
+        ),
+        mount_arguments,
+        config,
+        local_borg_version,
+        global_arguments,
+        local_path=local_path,
+        remote_path=remote_path,
+    )

+ 0 - 7
borgmatic/actions/prune.py

@@ -1,7 +1,6 @@
 import logging
 
 import borgmatic.borg.prune
-import borgmatic.config.validate
 import borgmatic.hooks.command
 
 logger = logging.getLogger(__name__)
@@ -21,12 +20,6 @@ def run_prune(
     '''
     Run the "prune" action for the given repository.
     '''
-    if prune_arguments.repository and not borgmatic.config.validate.repositories_match(
-        repository,
-        prune_arguments.repository,
-    ):
-        return
-
     logger.info(f'Pruning archives{dry_run_label}')
     borgmatic.borg.prune.prune_archives(
         global_arguments.dry_run,

+ 45 - 50
borgmatic/actions/recreate.py

@@ -4,7 +4,6 @@ import subprocess
 import borgmatic.borg.info
 import borgmatic.borg.recreate
 import borgmatic.borg.repo_list
-import borgmatic.config.validate
 from borgmatic.actions.pattern import collect_patterns, process_patterns
 
 logger = logging.getLogger(__name__)
@@ -25,64 +24,60 @@ def run_recreate(
     '''
     Run the "recreate" action for the given repository.
     '''
-    if recreate_arguments.repository is None or borgmatic.config.validate.repositories_match(
-        repository,
-        recreate_arguments.repository,
-    ):
-        if recreate_arguments.archive:
-            logger.answer(f'Recreating archive {recreate_arguments.archive}')
-        else:
-            logger.answer('Recreating repository')
+    if recreate_arguments.archive:
+        logger.answer(f'Recreating archive {recreate_arguments.archive}')
+    else:
+        logger.answer('Recreating repository')
 
-        # Collect and process patterns.
-        processed_patterns = process_patterns(
-            collect_patterns(config),
-            config,
-            borgmatic.config.paths.get_working_directory(config),
+    # Collect and process patterns.
+    processed_patterns = process_patterns(
+        collect_patterns(config),
+        config,
+        borgmatic.config.paths.get_working_directory(config),
+    )
+
+    archive = borgmatic.borg.repo_list.resolve_archive_name(
+        repository['path'],
+        recreate_arguments.archive,
+        config,
+        local_borg_version,
+        global_arguments,
+        local_path,
+        remote_path,
+    )
+
+    if archive and archive.endswith('.recreate'):
+        if recreate_arguments.archive == 'latest':
+            raise ValueError(
+                f'The latest archive "{archive}" is leftover from a prior recreate. Delete it first or select a different archive.',
+            )
+
+        raise ValueError(
+            f'The archive "{recreate_arguments.archive}" is leftover from a prior recreate. Select a different archive.',
         )
 
-        archive = borgmatic.borg.repo_list.resolve_archive_name(
+    try:
+        borgmatic.borg.recreate.recreate_archive(
             repository['path'],
-            recreate_arguments.archive,
+            archive,
             config,
             local_borg_version,
+            recreate_arguments,
             global_arguments,
-            local_path,
-            remote_path,
+            local_path=local_path,
+            remote_path=remote_path,
+            patterns=processed_patterns,
         )
-
-        if archive and archive.endswith('.recreate'):
-            if recreate_arguments.archive == 'latest':
+    except subprocess.CalledProcessError as error:
+        if error.returncode == BORG_EXIT_CODE_ARCHIVE_ALREADY_EXISTS:
+            if recreate_arguments.target:
                 raise ValueError(
-                    f'The latest archive "{archive}" is leftover from a prior recreate. Delete it first or select a different archive.',
+                    f'The archive "{recreate_arguments.target}" already exists. Delete it first or set a different target archive name.',
                 )
 
-            raise ValueError(
-                f'The archive "{recreate_arguments.archive}" is leftover from a prior recreate. Select a different archive.',
-            )
-
-        try:
-            borgmatic.borg.recreate.recreate_archive(
-                repository['path'],
-                archive,
-                config,
-                local_borg_version,
-                recreate_arguments,
-                global_arguments,
-                local_path=local_path,
-                remote_path=remote_path,
-                patterns=processed_patterns,
-            )
-        except subprocess.CalledProcessError as error:
-            if error.returncode == BORG_EXIT_CODE_ARCHIVE_ALREADY_EXISTS:
-                if recreate_arguments.target:
-                    raise ValueError(
-                        f'The archive "{recreate_arguments.target}" already exists. Delete it first or set a different target archive name.',
-                    )
-
-                if archive:
-                    raise ValueError(
-                        f'The archive "{archive}.recreate" is leftover from a prior recreate. Delete it first or select a different archive.',
-                    )
+            if archive:
+                raise ValueError(
+                    f'The archive "{archive}.recreate" is leftover from a prior recreate. Delete it first or select a different archive.',
+                )
 
-            raise
+        raise

+ 0 - 7
borgmatic/actions/repo_create.py

@@ -1,7 +1,6 @@
 import logging
 
 import borgmatic.borg.repo_create
-import borgmatic.config.validate
 
 logger = logging.getLogger(__name__)
 
@@ -18,12 +17,6 @@ def run_repo_create(
     '''
     Run the "repo-create" action for the given repository.
     '''
-    if repo_create_arguments.repository and not borgmatic.config.validate.repositories_match(
-        repository,
-        repo_create_arguments.repository,
-    ):
-        return
-
     logger.info('Creating repository')
 
     encryption_mode = repo_create_arguments.encryption_mode or repository.get('encryption')

+ 12 - 16
borgmatic/actions/repo_delete.py

@@ -17,20 +17,16 @@ def run_repo_delete(
     '''
     Run the "repo-delete" action for the given repository.
     '''
-    if repo_delete_arguments.repository is None or borgmatic.config.validate.repositories_match(
-        repository,
-        repo_delete_arguments.repository,
-    ):
-        logger.answer(
-            'Deleting repository' + (' cache' if repo_delete_arguments.cache_only else ''),
-        )
+    logger.answer(
+        'Deleting repository' + (' cache' if repo_delete_arguments.cache_only else ''),
+    )
 
-        borgmatic.borg.repo_delete.delete_repository(
-            repository,
-            config,
-            local_borg_version,
-            repo_delete_arguments,
-            global_arguments,
-            local_path,
-            remote_path,
-        )
+    borgmatic.borg.repo_delete.delete_repository(
+        repository,
+        config,
+        local_borg_version,
+        repo_delete_arguments,
+        global_arguments,
+        local_path,
+        remote_path,
+    )

+ 13 - 18
borgmatic/actions/repo_info.py

@@ -2,7 +2,6 @@ import logging
 
 import borgmatic.actions.json
 import borgmatic.borg.repo_info
-import borgmatic.config.validate
 
 logger = logging.getLogger(__name__)
 
@@ -21,21 +20,17 @@ def run_repo_info(
 
     If repo_info_arguments.json is True, yield the JSON output from the info for the repository.
     '''
-    if repo_info_arguments.repository is None or borgmatic.config.validate.repositories_match(
-        repository,
-        repo_info_arguments.repository,
-    ):
-        if not repo_info_arguments.json:
-            logger.answer('Displaying repository summary information')
+    if not repo_info_arguments.json:
+        logger.answer('Displaying repository summary information')
 
-        json_output = borgmatic.borg.repo_info.display_repository_info(
-            repository['path'],
-            config,
-            local_borg_version,
-            repo_info_arguments=repo_info_arguments,
-            global_arguments=global_arguments,
-            local_path=local_path,
-            remote_path=remote_path,
-        )
-        if json_output:
-            yield borgmatic.actions.json.parse_json(json_output, repository.get('label'))
+    json_output = borgmatic.borg.repo_info.display_repository_info(
+        repository['path'],
+        config,
+        local_borg_version,
+        repo_info_arguments=repo_info_arguments,
+        global_arguments=global_arguments,
+        local_path=local_path,
+        remote_path=remote_path,
+    )
+    if json_output:
+        yield borgmatic.actions.json.parse_json(json_output, repository.get('label'))

+ 13 - 18
borgmatic/actions/repo_list.py

@@ -2,7 +2,6 @@ import logging
 
 import borgmatic.actions.json
 import borgmatic.borg.repo_list
-import borgmatic.config.validate
 
 logger = logging.getLogger(__name__)
 
@@ -21,21 +20,17 @@ def run_repo_list(
 
     If repo_list_arguments.json is True, yield the JSON output from listing the repository.
     '''
-    if repo_list_arguments.repository is None or borgmatic.config.validate.repositories_match(
-        repository,
-        repo_list_arguments.repository,
-    ):
-        if not repo_list_arguments.json:
-            logger.answer('Listing repository')
+    if not repo_list_arguments.json:
+        logger.answer('Listing repository')
 
-        json_output = borgmatic.borg.repo_list.list_repository(
-            repository['path'],
-            config,
-            local_borg_version,
-            repo_list_arguments=repo_list_arguments,
-            global_arguments=global_arguments,
-            local_path=local_path,
-            remote_path=remote_path,
-        )
-        if json_output:
-            yield borgmatic.actions.json.parse_json(json_output, repository.get('label'))
+    json_output = borgmatic.borg.repo_list.list_repository(
+        repository['path'],
+        config,
+        local_borg_version,
+        repo_list_arguments=repo_list_arguments,
+        global_arguments=global_arguments,
+        local_path=local_path,
+        remote_path=remote_path,
+    )
+    if json_output:
+        yield borgmatic.actions.json.parse_json(json_output, repository.get('label'))

+ 1 - 9
borgmatic/actions/restore.py

@@ -11,7 +11,6 @@ import borgmatic.borg.list
 import borgmatic.borg.mount
 import borgmatic.borg.repo_list
 import borgmatic.config.paths
-import borgmatic.config.validate
 import borgmatic.hooks.data_source.dump
 import borgmatic.hooks.dispatch
 
@@ -524,18 +523,11 @@ def run_restore(
     remote_path,
 ):
     '''
-    Run the "restore" action for the given repository, but only if the repository matches the
-    requested repository in restore arguments.
+    Run the "restore" action for the given repository.
 
     Raise ValueError if a configured data source could not be found to restore or there's no
     matching dump in the archive.
     '''
-    if restore_arguments.repository and not borgmatic.config.validate.repositories_match(
-        repository,
-        restore_arguments.repository,
-    ):
-        return
-
     logger.info(f'Restoring data sources from archive {restore_arguments.archive}')
     working_directory = borgmatic.config.paths.get_working_directory(config)
 

+ 17 - 1
borgmatic/commands/borgmatic.py

@@ -340,7 +340,7 @@ def run_actions(  # noqa: PLR0912, PLR0915
     '''
     Given parsed command-line arguments as an argparse.ArgumentParser instance, the configuration
     filename, a configuration dict, a sequence of loaded configuration paths, local and remote paths
-    to Borg, a local Borg version string, and a repository name, run all actions from the
+    to Borg, a local Borg version string, and a repository dict, run all actions from the
     command-line arguments on the given repository.
 
     Yield JSON output strings from executing any actions that produce JSON.
@@ -362,6 +362,22 @@ def run_actions(  # noqa: PLR0912, PLR0915
         'repository': repository_path,
     }
     skip_actions = set(get_skip_actions(config, arguments))
+    requested_repository = next(
+        (
+            repository
+            for action_arguments in arguments.values()
+            for repository in (getattr(action_arguments, 'repository', None),)
+            if repository is not None
+        ),
+        None,
+    )
+
+    if requested_repository and not borgmatic.config.validate.repositories_match(
+        repository,
+        requested_repository,
+    ):
+        logger.debug('Skipping actions because the requested --repository does not match')
+        return
 
     with borgmatic.hooks.command.Before_after_hooks(
         command_hooks=config.get('commands'),

+ 0 - 1
tests/unit/actions/test_borg.py

@@ -5,7 +5,6 @@ from borgmatic.actions import borg as module
 
 def test_run_borg_does_not_raise():
     flexmock(module.logger).answer = lambda message: None
-    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').and_return(True)
     flexmock(module.borgmatic.borg.repo_list).should_receive('resolve_archive_name').and_return(
         flexmock(),
     )

+ 0 - 1
tests/unit/actions/test_break_lock.py

@@ -5,7 +5,6 @@ from borgmatic.actions import break_lock as module
 
 def test_run_break_lock_does_not_raise():
     flexmock(module.logger).answer = lambda message: None
-    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').and_return(True)
     flexmock(module.borgmatic.borg.break_lock).should_receive('break_lock')
     break_lock_arguments = flexmock(repository=flexmock())
 

+ 0 - 1
tests/unit/actions/test_change_passphrase.py

@@ -5,7 +5,6 @@ from borgmatic.actions import change_passphrase as module
 
 def test_run_change_passphrase_does_not_raise():
     flexmock(module.logger).answer = lambda message: None
-    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').and_return(True)
     flexmock(module.borgmatic.borg.change_passphrase).should_receive('change_passphrase')
     change_passphrase_arguments = flexmock(repository=flexmock())
 

+ 0 - 69
tests/unit/actions/test_check.py

@@ -1530,7 +1530,6 @@ def test_spot_check_without_any_source_paths_errors():
 
 def test_run_check_checks_archives_for_configured_repository():
     flexmock(module.logger).answer = lambda message: None
-    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').never()
     flexmock(module.borgmatic.borg.check).should_receive('get_repository_id').and_return(flexmock())
     flexmock(module).should_receive('upgrade_check_times')
     flexmock(module).should_receive('parse_checks')
@@ -1566,7 +1565,6 @@ def test_run_check_checks_archives_for_configured_repository():
 
 def test_run_check_runs_configured_extract_check():
     flexmock(module.logger).answer = lambda message: None
-    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').never()
     flexmock(module.borgmatic.borg.check).should_receive('get_repository_id').and_return(flexmock())
     flexmock(module).should_receive('upgrade_check_times')
     flexmock(module).should_receive('parse_checks')
@@ -1600,7 +1598,6 @@ def test_run_check_runs_configured_extract_check():
 
 def test_run_check_runs_configured_spot_check():
     flexmock(module.logger).answer = lambda message: None
-    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').never()
     flexmock(module.borgmatic.borg.check).should_receive('get_repository_id').and_return(flexmock())
     flexmock(module).should_receive('upgrade_check_times')
     flexmock(module).should_receive('parse_checks')
@@ -1637,7 +1634,6 @@ def test_run_check_runs_configured_spot_check():
 
 def test_run_check_without_checks_runs_nothing_except_hooks():
     flexmock(module.logger).answer = lambda message: None
-    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').never()
     flexmock(module.borgmatic.borg.check).should_receive('get_repository_id').and_return(flexmock())
     flexmock(module).should_receive('upgrade_check_times')
     flexmock(module).should_receive('parse_checks')
@@ -1667,68 +1663,3 @@ def test_run_check_without_checks_runs_nothing_except_hooks():
         local_path=None,
         remote_path=None,
     )
-
-
-def test_run_check_checks_archives_in_selected_repository():
-    flexmock(module.logger).answer = lambda message: None
-    flexmock(module.borgmatic.config.validate).should_receive(
-        'repositories_match',
-    ).once().and_return(True)
-    flexmock(module.borgmatic.borg.check).should_receive('get_repository_id').and_return(flexmock())
-    flexmock(module).should_receive('upgrade_check_times')
-    flexmock(module).should_receive('parse_checks')
-    flexmock(module.borgmatic.borg.check).should_receive('make_archive_filter_flags').and_return(())
-    flexmock(module).should_receive('make_archives_check_id').and_return(None)
-    flexmock(module).should_receive('filter_checks_on_frequency').and_return(
-        {'repository', 'archives'},
-    )
-    flexmock(module.borgmatic.borg.check).should_receive('check_archives').once()
-    flexmock(module).should_receive('make_check_time_path')
-    flexmock(module).should_receive('write_check_time')
-    flexmock(module.borgmatic.borg.extract).should_receive('extract_last_archive_dry_run').never()
-    check_arguments = flexmock(
-        repository=flexmock(),
-        progress=flexmock(),
-        repair=flexmock(),
-        only_checks=flexmock(),
-        force=flexmock(),
-    )
-    global_arguments = flexmock(monitoring_verbosity=1, dry_run=False)
-
-    module.run_check(
-        config_filename='test.yaml',
-        repository={'path': 'repo'},
-        config={'repositories': ['repo']},
-        local_borg_version=None,
-        check_arguments=check_arguments,
-        global_arguments=global_arguments,
-        local_path=None,
-        remote_path=None,
-    )
-
-
-def test_run_check_bails_if_repository_does_not_match():
-    flexmock(module.logger).answer = lambda message: None
-    flexmock(module.borgmatic.config.validate).should_receive(
-        'repositories_match',
-    ).once().and_return(False)
-    flexmock(module.borgmatic.borg.check).should_receive('check_archives').never()
-    check_arguments = flexmock(
-        repository=flexmock(),
-        progress=flexmock(),
-        repair=flexmock(),
-        only_checks=flexmock(),
-        force=flexmock(),
-    )
-    global_arguments = flexmock(monitoring_verbosity=1, dry_run=False)
-
-    module.run_check(
-        config_filename='test.yaml',
-        repository={'path': 'repo'},
-        config={'repositories': ['repo']},
-        local_borg_version=None,
-        check_arguments=check_arguments,
-        global_arguments=global_arguments,
-        local_path=None,
-        remote_path=None,
-    )

+ 0 - 57
tests/unit/actions/test_compact.py

@@ -6,7 +6,6 @@ from borgmatic.actions import compact as module
 def test_compact_actions_calls_hooks_for_configured_repository():
     flexmock(module.logger).answer = lambda message: None
     flexmock(module.borgmatic.borg.feature).should_receive('available').and_return(True)
-    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').never()
     flexmock(module.borgmatic.borg.compact).should_receive('compact_segments').once()
     compact_arguments = flexmock(
         repository=None,
@@ -27,59 +26,3 @@ def test_compact_actions_calls_hooks_for_configured_repository():
         local_path=None,
         remote_path=None,
     )
-
-
-def test_compact_runs_with_selected_repository():
-    flexmock(module.logger).answer = lambda message: None
-    flexmock(module.borgmatic.config.validate).should_receive(
-        'repositories_match',
-    ).once().and_return(True)
-    flexmock(module.borgmatic.borg.feature).should_receive('available').and_return(True)
-    flexmock(module.borgmatic.borg.compact).should_receive('compact_segments').once()
-    compact_arguments = flexmock(
-        repository=flexmock(),
-        progress=flexmock(),
-        cleanup_commits=flexmock(),
-        compact_threshold=flexmock(),
-    )
-    global_arguments = flexmock(monitoring_verbosity=1, dry_run=False)
-
-    module.run_compact(
-        config_filename='test.yaml',
-        repository={'path': 'repo'},
-        config={},
-        local_borg_version=None,
-        compact_arguments=compact_arguments,
-        global_arguments=global_arguments,
-        dry_run_label='',
-        local_path=None,
-        remote_path=None,
-    )
-
-
-def test_compact_bails_if_repository_does_not_match():
-    flexmock(module.logger).answer = lambda message: None
-    flexmock(module.borgmatic.borg.feature).should_receive('available').and_return(True)
-    flexmock(module.borgmatic.config.validate).should_receive(
-        'repositories_match',
-    ).once().and_return(False)
-    flexmock(module.borgmatic.borg.compact).should_receive('compact_segments').never()
-    compact_arguments = flexmock(
-        repository=flexmock(),
-        progress=flexmock(),
-        cleanup_commits=flexmock(),
-        compact_threshold=flexmock(),
-    )
-    global_arguments = flexmock(monitoring_verbosity=1, dry_run=False)
-
-    module.run_compact(
-        config_filename='test.yaml',
-        repository={'path': 'repo'},
-        config={},
-        local_borg_version=None,
-        compact_arguments=compact_arguments,
-        global_arguments=global_arguments,
-        dry_run_label='',
-        local_path=None,
-        remote_path=None,
-    )

+ 0 - 88
tests/unit/actions/test_create.py

@@ -9,7 +9,6 @@ from borgmatic.actions import create as module
 
 def test_run_create_executes_and_calls_hooks_for_configured_repository():
     flexmock(module.logger).answer = lambda message: None
-    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').never()
     flexmock(module.borgmatic.config.paths).should_receive('Runtime_directory').and_return(
         flexmock(),
     )
@@ -48,87 +47,8 @@ def test_run_create_executes_and_calls_hooks_for_configured_repository():
     )
 
 
-def test_run_create_runs_with_selected_repository():
-    flexmock(module.logger).answer = lambda message: None
-    flexmock(module.borgmatic.config.validate).should_receive(
-        'repositories_match',
-    ).once().and_return(True)
-    flexmock(module.borgmatic.config.paths).should_receive('Runtime_directory').and_return(
-        flexmock(),
-    )
-    flexmock(module.borgmatic.borg.create).should_receive('create_archive').once()
-    flexmock(module.borgmatic.hooks.dispatch).should_receive('call_hooks').and_return({})
-    flexmock(module.borgmatic.hooks.dispatch).should_receive(
-        'call_hooks_even_if_unconfigured',
-    ).and_return({})
-    flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(None)
-    flexmock(module.borgmatic.actions.pattern).should_receive('collect_patterns').and_return(())
-    flexmock(module.borgmatic.actions.pattern).should_receive('process_patterns').and_return([])
-    flexmock(os.path).should_receive('join').and_return('/run/borgmatic/bootstrap')
-    create_arguments = flexmock(
-        repository=flexmock(),
-        progress=flexmock(),
-        statistics=flexmock(),
-        json=False,
-        comment=None,
-        list_details=flexmock(),
-    )
-    global_arguments = flexmock(monitoring_verbosity=1, dry_run=False)
-
-    list(
-        module.run_create(
-            config_filename='test.yaml',
-            repository={'path': 'repo'},
-            config={},
-            config_paths=['/tmp/test.yaml'],
-            local_borg_version=None,
-            create_arguments=create_arguments,
-            global_arguments=global_arguments,
-            dry_run_label='',
-            local_path=None,
-            remote_path=None,
-        ),
-    )
-
-
-def test_run_create_bails_if_repository_does_not_match():
-    flexmock(module.logger).answer = lambda message: None
-    flexmock(module.borgmatic.config.validate).should_receive(
-        'repositories_match',
-    ).once().and_return(False)
-    flexmock(module.borgmatic.config.paths).should_receive('Runtime_directory').never()
-    flexmock(module.borgmatic.borg.create).should_receive('create_archive').never()
-    create_arguments = flexmock(
-        repository=flexmock(),
-        progress=flexmock(),
-        statistics=flexmock(),
-        json=False,
-        comment=None,
-        list_details=flexmock(),
-    )
-    global_arguments = flexmock(monitoring_verbosity=1, dry_run=False)
-
-    list(
-        module.run_create(
-            config_filename='test.yaml',
-            repository='repo',
-            config={},
-            config_paths=['/tmp/test.yaml'],
-            local_borg_version=None,
-            create_arguments=create_arguments,
-            global_arguments=global_arguments,
-            dry_run_label='',
-            local_path=None,
-            remote_path=None,
-        ),
-    )
-
-
 def test_run_create_with_both_list_and_json_errors():
     flexmock(module.logger).answer = lambda message: None
-    flexmock(module.borgmatic.config.validate).should_receive(
-        'repositories_match',
-    ).once().and_return(True)
     flexmock(module.borgmatic.config.paths).should_receive('Runtime_directory').never()
     flexmock(module.borgmatic.borg.create).should_receive('create_archive').never()
     create_arguments = flexmock(
@@ -160,9 +80,6 @@ def test_run_create_with_both_list_and_json_errors():
 
 def test_run_create_with_both_list_and_progress_errors():
     flexmock(module.logger).answer = lambda message: None
-    flexmock(module.borgmatic.config.validate).should_receive(
-        'repositories_match',
-    ).once().and_return(True)
     flexmock(module.borgmatic.config.paths).should_receive('Runtime_directory').never()
     flexmock(module.borgmatic.borg.create).should_receive('create_archive').never()
     create_arguments = flexmock(
@@ -194,9 +111,6 @@ def test_run_create_with_both_list_and_progress_errors():
 
 def test_run_create_produces_json():
     flexmock(module.logger).answer = lambda message: None
-    flexmock(module.borgmatic.config.validate).should_receive(
-        'repositories_match',
-    ).once().and_return(True)
     flexmock(module.borgmatic.config.paths).should_receive('Runtime_directory').and_return(
         flexmock(),
     )
@@ -244,7 +158,6 @@ def test_run_create_with_active_dumps_roundtrips_via_checkpoint_archive():
     mock_dump_process.should_receive('poll').and_return(None).and_return(0)
 
     flexmock(module.logger).answer = lambda message: None
-    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').never()
     flexmock(module.borgmatic.config.paths).should_receive('Runtime_directory').and_return(
         flexmock(),
     )
@@ -325,7 +238,6 @@ def test_run_create_with_active_dumps_json_updates_archive_info():
     }
 
     flexmock(module.logger).answer = lambda message: None
-    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').never()
     flexmock(module.borgmatic.config.paths).should_receive('Runtime_directory').and_return(
         flexmock(),
     )

+ 0 - 2
tests/unit/actions/test_delete.py

@@ -5,7 +5,6 @@ from borgmatic.actions import delete as module
 
 def test_run_delete_does_not_raise():
     flexmock(module.logger).answer = lambda message: None
-    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').and_return(True)
     flexmock(module.borgmatic.borg.repo_list).should_receive('resolve_archive_name')
     flexmock(module.borgmatic.actions.arguments).should_receive('update_arguments').and_return(
         flexmock(),
@@ -25,7 +24,6 @@ def test_run_delete_does_not_raise():
 
 def test_run_delete_without_archive_does_not_raise():
     flexmock(module.logger).answer = lambda message: None
-    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').and_return(True)
     flexmock(module.borgmatic.borg.repo_list).should_receive('resolve_archive_name')
     flexmock(module.borgmatic.actions.arguments).should_receive('update_arguments').and_return(
         flexmock(),

+ 0 - 1
tests/unit/actions/test_export_key.py

@@ -5,7 +5,6 @@ from borgmatic.actions import export_key as module
 
 def test_run_export_key_does_not_raise():
     flexmock(module.logger).answer = lambda message: None
-    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').and_return(True)
     flexmock(module.borgmatic.borg.export_key).should_receive('export_key')
     export_arguments = flexmock(repository=flexmock())
 

+ 0 - 3
tests/unit/actions/test_export_tar.py

@@ -5,7 +5,6 @@ from borgmatic.actions import export_tar as module
 
 def test_run_export_tar_does_not_raise():
     flexmock(module.logger).answer = lambda message: None
-    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').and_return(True)
     flexmock(module.borgmatic.borg.export_tar).should_receive('export_tar_archive')
     export_tar_arguments = flexmock(
         repository=flexmock(),
@@ -31,7 +30,6 @@ def test_run_export_tar_does_not_raise():
 
 def test_run_export_tar_favors_flags_over_config():
     flexmock(module.logger).answer = lambda message: None
-    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').and_return(True)
     flexmock(module.borgmatic.borg.export_tar).should_receive('export_tar_archive').with_args(
         object,
         object,
@@ -70,7 +68,6 @@ def test_run_export_tar_favors_flags_over_config():
 
 def test_run_export_tar_defaults_to_config():
     flexmock(module.logger).answer = lambda message: None
-    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').and_return(True)
     flexmock(module.borgmatic.borg.export_tar).should_receive('export_tar_archive').with_args(
         object,
         object,

+ 0 - 3
tests/unit/actions/test_extract.py

@@ -5,7 +5,6 @@ from borgmatic.actions import extract as module
 
 def test_run_extract_calls_hooks():
     flexmock(module.logger).answer = lambda message: None
-    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').and_return(True)
     flexmock(module.borgmatic.borg.extract).should_receive('extract_archive')
     extract_arguments = flexmock(
         paths=flexmock(),
@@ -31,7 +30,6 @@ def test_run_extract_calls_hooks():
 
 def test_run_extract_favors_flags_over_config():
     flexmock(module.logger).answer = lambda message: None
-    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').and_return(True)
     flexmock(module.borgmatic.borg.extract).should_receive('extract_archive').with_args(
         object,
         object,
@@ -69,7 +67,6 @@ def test_run_extract_favors_flags_over_config():
 
 def test_run_extract_defaults_to_config():
     flexmock(module.logger).answer = lambda message: None
-    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').and_return(True)
     flexmock(module.borgmatic.borg.extract).should_receive('extract_archive').with_args(
         object,
         object,

+ 0 - 1
tests/unit/actions/test_import_key.py

@@ -5,7 +5,6 @@ from borgmatic.actions import import_key as module
 
 def test_run_import_key_does_not_raise():
     flexmock(module.logger).answer = lambda message: None
-    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').and_return(True)
     flexmock(module.borgmatic.borg.import_key).should_receive('import_key')
     import_arguments = flexmock(repository=flexmock())
 

+ 0 - 2
tests/unit/actions/test_info.py

@@ -5,7 +5,6 @@ from borgmatic.actions import info as module
 
 def test_run_info_does_not_raise():
     flexmock(module.logger).answer = lambda message: None
-    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').and_return(True)
     flexmock(module.borgmatic.borg.repo_list).should_receive('resolve_archive_name').and_return(
         flexmock(),
     )
@@ -30,7 +29,6 @@ def test_run_info_does_not_raise():
 
 def test_run_info_produces_json():
     flexmock(module.logger).answer = lambda message: None
-    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').and_return(True)
     flexmock(module.borgmatic.borg.repo_list).should_receive('resolve_archive_name').and_return(
         flexmock(),
     )

+ 0 - 2
tests/unit/actions/test_list.py

@@ -5,7 +5,6 @@ from borgmatic.actions import list as module
 
 def test_run_list_does_not_raise():
     flexmock(module.logger).answer = lambda message: None
-    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').and_return(True)
     flexmock(module.borgmatic.borg.repo_list).should_receive('resolve_archive_name').and_return(
         flexmock(),
     )
@@ -35,7 +34,6 @@ def test_run_list_does_not_raise():
 
 def test_run_list_produces_json():
     flexmock(module.logger).answer = lambda message: None
-    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').and_return(True)
     flexmock(module.borgmatic.borg.repo_list).should_receive('resolve_archive_name').and_return(
         flexmock(),
     )

+ 0 - 1
tests/unit/actions/test_mount.py

@@ -5,7 +5,6 @@ from borgmatic.actions import mount as module
 
 def test_run_mount_does_not_raise():
     flexmock(module.logger).answer = lambda message: None
-    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').and_return(True)
     flexmock(module.borgmatic.borg.mount).should_receive('mount_archive')
     mount_arguments = flexmock(
         repository=flexmock(),

+ 0 - 53
tests/unit/actions/test_prune.py

@@ -5,7 +5,6 @@ from borgmatic.actions import prune as module
 
 def test_run_prune_calls_hooks_for_configured_repository():
     flexmock(module.logger).answer = lambda message: None
-    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').never()
     flexmock(module.borgmatic.borg.prune).should_receive('prune_archives').once()
     prune_arguments = flexmock(repository=None, statistics=flexmock(), list_details=flexmock())
     global_arguments = flexmock(monitoring_verbosity=1, dry_run=False)
@@ -21,55 +20,3 @@ def test_run_prune_calls_hooks_for_configured_repository():
         local_path=None,
         remote_path=None,
     )
-
-
-def test_run_prune_runs_with_selected_repository():
-    flexmock(module.logger).answer = lambda message: None
-    flexmock(module.borgmatic.config.validate).should_receive(
-        'repositories_match',
-    ).once().and_return(True)
-    flexmock(module.borgmatic.borg.prune).should_receive('prune_archives').once()
-    prune_arguments = flexmock(
-        repository=flexmock(),
-        statistics=flexmock(),
-        list_details=flexmock(),
-    )
-    global_arguments = flexmock(monitoring_verbosity=1, dry_run=False)
-
-    module.run_prune(
-        config_filename='test.yaml',
-        repository={'path': 'repo'},
-        config={},
-        local_borg_version=None,
-        prune_arguments=prune_arguments,
-        global_arguments=global_arguments,
-        dry_run_label='',
-        local_path=None,
-        remote_path=None,
-    )
-
-
-def test_run_prune_bails_if_repository_does_not_match():
-    flexmock(module.logger).answer = lambda message: None
-    flexmock(module.borgmatic.config.validate).should_receive(
-        'repositories_match',
-    ).once().and_return(False)
-    flexmock(module.borgmatic.borg.prune).should_receive('prune_archives').never()
-    prune_arguments = flexmock(
-        repository=flexmock(),
-        statistics=flexmock(),
-        list_details=flexmock(),
-    )
-    global_arguments = flexmock(monitoring_verbosity=1, dry_run=False)
-
-    module.run_prune(
-        config_filename='test.yaml',
-        repository='repo',
-        config={},
-        local_borg_version=None,
-        prune_arguments=prune_arguments,
-        global_arguments=global_arguments,
-        dry_run_label='',
-        local_path=None,
-        remote_path=None,
-    )

+ 0 - 7
tests/unit/actions/test_recreate.py

@@ -6,7 +6,6 @@ from borgmatic.actions import recreate as module
 
 def test_run_recreate_does_not_raise():
     flexmock(module.logger).answer = lambda message: None
-    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').and_return(True)
     flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(
         flexmock(),
     )
@@ -28,7 +27,6 @@ def test_run_recreate_does_not_raise():
 
 def test_run_recreate_with_archive_does_not_raise():
     flexmock(module.logger).answer = lambda message: None
-    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').and_return(True)
     flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(
         flexmock(),
     )
@@ -50,7 +48,6 @@ def test_run_recreate_with_archive_does_not_raise():
 
 def test_run_recreate_with_leftover_recreate_archive_raises():
     flexmock(module.logger).answer = lambda message: None
-    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').and_return(True)
     flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(
         flexmock(),
     )
@@ -73,7 +70,6 @@ def test_run_recreate_with_leftover_recreate_archive_raises():
 
 def test_run_recreate_with_latest_archive_resolving_to_leftover_recreate_archive_raises():
     flexmock(module.logger).answer = lambda message: None
-    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').and_return(True)
     flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(
         flexmock(),
     )
@@ -96,7 +92,6 @@ def test_run_recreate_with_latest_archive_resolving_to_leftover_recreate_archive
 
 def test_run_recreate_with_archive_already_exists_error_raises():
     flexmock(module.logger).answer = lambda message: None
-    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').and_return(True)
     flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(
         flexmock(),
     )
@@ -124,7 +119,6 @@ def test_run_recreate_with_archive_already_exists_error_raises():
 
 def test_run_recreate_with_target_and_archive_already_exists_error_raises():
     flexmock(module.logger).answer = lambda message: None
-    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').and_return(True)
     flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(
         flexmock(),
     )
@@ -156,7 +150,6 @@ def test_run_recreate_with_target_and_archive_already_exists_error_raises():
 
 def test_run_recreate_with_other_called_process_error_passes_it_through():
     flexmock(module.logger).answer = lambda message: None
-    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').and_return(True)
     flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(
         flexmock(),
     )

+ 0 - 32
tests/unit/actions/test_repo_create.py

@@ -6,7 +6,6 @@ from borgmatic.actions import repo_create as module
 
 def test_run_repo_create_with_encryption_mode_argument_does_not_raise():
     flexmock(module.logger).answer = lambda message: None
-    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').and_return(True)
     flexmock(module.borgmatic.borg.repo_create).should_receive('create_repository')
     arguments = flexmock(
         encryption_mode=flexmock(),
@@ -31,7 +30,6 @@ def test_run_repo_create_with_encryption_mode_argument_does_not_raise():
 
 def test_run_repo_create_with_encryption_mode_option_does_not_raise():
     flexmock(module.logger).answer = lambda message: None
-    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').and_return(True)
     flexmock(module.borgmatic.borg.repo_create).should_receive('create_repository')
     arguments = flexmock(
         encryption_mode=None,
@@ -56,7 +54,6 @@ def test_run_repo_create_with_encryption_mode_option_does_not_raise():
 
 def test_run_repo_create_without_encryption_mode_raises():
     flexmock(module.logger).answer = lambda message: None
-    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').and_return(True)
     flexmock(module.borgmatic.borg.repo_create).should_receive('create_repository')
     arguments = flexmock(
         encryption_mode=None,
@@ -80,36 +77,8 @@ def test_run_repo_create_without_encryption_mode_raises():
         )
 
 
-def test_run_repo_create_bails_if_repository_does_not_match():
-    flexmock(module.logger).answer = lambda message: None
-    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').and_return(
-        False,
-    )
-    flexmock(module.borgmatic.borg.repo_create).should_receive('create_repository').never()
-    arguments = flexmock(
-        encryption_mode=flexmock(),
-        source_repository=flexmock(),
-        repository=flexmock(),
-        copy_crypt_key=flexmock(),
-        append_only=flexmock(),
-        storage_quota=flexmock(),
-        make_parent_directories=flexmock(),
-    )
-
-    module.run_repo_create(
-        repository={'path': 'repo'},
-        config={},
-        local_borg_version=None,
-        repo_create_arguments=arguments,
-        global_arguments=flexmock(dry_run=False),
-        local_path=None,
-        remote_path=None,
-    )
-
-
 def test_run_repo_create_favors_flags_over_config():
     flexmock(module.logger).answer = lambda message: None
-    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').and_return(True)
     flexmock(module.borgmatic.borg.repo_create).should_receive('create_repository').with_args(
         object,
         object,
@@ -153,7 +122,6 @@ def test_run_repo_create_favors_flags_over_config():
 
 def test_run_repo_create_defaults_to_config():
     flexmock(module.logger).answer = lambda message: None
-    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').and_return(True)
     flexmock(module.borgmatic.borg.repo_create).should_receive('create_repository').with_args(
         object,
         object,

+ 0 - 2
tests/unit/actions/test_repo_delete.py

@@ -5,7 +5,6 @@ from borgmatic.actions import repo_delete as module
 
 def test_run_repo_delete_does_not_raise():
     flexmock(module.logger).answer = lambda message: None
-    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').and_return(True)
     flexmock(module.borgmatic.actions.arguments).should_receive('update_arguments').and_return(
         flexmock(),
     )
@@ -24,7 +23,6 @@ def test_run_repo_delete_does_not_raise():
 
 def test_run_repo_delete_with_cache_only_does_not_raise():
     flexmock(module.logger).answer = lambda message: None
-    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').and_return(True)
     flexmock(module.borgmatic.actions.arguments).should_receive('update_arguments').and_return(
         flexmock(),
     )

+ 0 - 2
tests/unit/actions/test_repo_info.py

@@ -5,7 +5,6 @@ from borgmatic.actions import repo_info as module
 
 def test_run_repo_info_does_not_raise():
     flexmock(module.logger).answer = lambda message: None
-    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').and_return(True)
     flexmock(module.borgmatic.borg.repo_info).should_receive('display_repository_info')
     repo_info_arguments = flexmock(repository=flexmock(), json=False)
 
@@ -24,7 +23,6 @@ def test_run_repo_info_does_not_raise():
 
 def test_run_repo_info_parses_json():
     flexmock(module.logger).answer = lambda message: None
-    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').and_return(True)
     flexmock(module.borgmatic.borg.repo_info).should_receive('display_repository_info').and_return(
         flexmock(),
     )

+ 0 - 2
tests/unit/actions/test_repo_list.py

@@ -5,7 +5,6 @@ from borgmatic.actions import repo_list as module
 
 def test_run_repo_list_does_not_raise():
     flexmock(module.logger).answer = lambda message: None
-    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').and_return(True)
     flexmock(module.borgmatic.borg.repo_list).should_receive('list_repository')
     repo_list_arguments = flexmock(repository=flexmock(), json=False)
 
@@ -24,7 +23,6 @@ def test_run_repo_list_does_not_raise():
 
 def test_run_repo_list_produces_json():
     flexmock(module.logger).answer = lambda message: None
-    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').and_return(True)
     flexmock(module.borgmatic.borg.repo_list).should_receive('list_repository').and_return(
         flexmock(),
     )

+ 0 - 34
tests/unit/actions/test_restore.py

@@ -1168,7 +1168,6 @@ def test_run_restore_restores_each_data_source():
         module.Dump(hook_name='postgresql_databases', data_source_name='bar'),
     }
 
-    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').and_return(True)
     borgmatic_runtime_directory = flexmock()
     flexmock(module.borgmatic.config.paths).should_receive('Runtime_directory').and_return(
         borgmatic_runtime_directory,
@@ -1238,41 +1237,11 @@ def test_run_restore_restores_each_data_source():
     )
 
 
-def test_run_restore_bails_for_non_matching_repository():
-    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').and_return(
-        False,
-    )
-    flexmock(module.borgmatic.config.paths).should_receive('Runtime_directory').and_return(
-        flexmock(),
-    )
-    flexmock(module.borgmatic.config.paths).should_receive(
-        'make_runtime_directory_glob',
-    ).replace_with(lambda path: path)
-    flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(None)
-    flexmock(module.borgmatic.actions.pattern).should_receive('collect_patterns').and_return(())
-    flexmock(module.borgmatic.actions.pattern).should_receive('process_patterns').and_return([])
-    flexmock(module.borgmatic.hooks.dispatch).should_receive(
-        'call_hooks_even_if_unconfigured',
-    ).never()
-    flexmock(module).should_receive('restore_single_dump').never()
-
-    module.run_restore(
-        repository={'path': 'repo'},
-        config=flexmock(),
-        local_borg_version=flexmock(),
-        restore_arguments=flexmock(repository='repo', archive='archive', data_sources=flexmock()),
-        global_arguments=flexmock(dry_run=False),
-        local_path=flexmock(),
-        remote_path=flexmock(),
-    )
-
-
 def test_run_restore_restores_data_source_by_falling_back_to_all_name():
     dumps_to_restore = {
         module.Dump(hook_name='postgresql_databases', data_source_name='foo'),
     }
 
-    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').and_return(True)
     borgmatic_runtime_directory = flexmock()
     flexmock(module.borgmatic.config.paths).should_receive('Runtime_directory').and_return(
         borgmatic_runtime_directory,
@@ -1335,7 +1304,6 @@ def test_run_restore_restores_data_source_configured_with_all_name():
         module.Dump(hook_name='postgresql_databases', data_source_name='bar'),
     }
 
-    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').and_return(True)
     borgmatic_runtime_directory = flexmock()
     flexmock(module.borgmatic.config.paths).should_receive('Runtime_directory').and_return(
         borgmatic_runtime_directory,
@@ -1420,7 +1388,6 @@ def test_run_restore_skips_missing_data_source():
         module.Dump(hook_name='postgresql_databases', data_source_name='bar'),
     }
 
-    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').and_return(True)
     borgmatic_runtime_directory = flexmock()
     flexmock(module.borgmatic.config.paths).should_receive('Runtime_directory').and_return(
         borgmatic_runtime_directory,
@@ -1505,7 +1472,6 @@ def test_run_restore_restores_data_sources_from_different_hooks():
         module.Dump(hook_name='mysql_databases', data_source_name='foo'),
     }
 
-    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').and_return(True)
     borgmatic_runtime_directory = flexmock()
     flexmock(module.borgmatic.config.paths).should_receive('Runtime_directory').and_return(
         borgmatic_runtime_directory,

+ 82 - 0
tests/unit/commands/test_borgmatic.py

@@ -939,6 +939,7 @@ def test_run_configuration_with_multiple_repositories_retries_with_timeout():
 def test_run_actions_runs_repo_create():
     flexmock(module).should_receive('add_custom_log_levels')
     flexmock(module).should_receive('get_skip_actions').and_return([])
+    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').never()
     flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(
         flexmock(),
     )
@@ -962,9 +963,64 @@ def test_run_actions_runs_repo_create():
     )
 
 
+def test_run_actions_with_matching_repository_flag_runs_repo_create():
+    flexmock(module).should_receive('add_custom_log_levels')
+    flexmock(module).should_receive('get_skip_actions').and_return([])
+    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').and_return(True)
+    flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(
+        flexmock(),
+    )
+    flexmock(module.command).should_receive('Before_after_hooks').and_return(flexmock())
+    flexmock(borgmatic.actions.repo_create).should_receive('run_repo_create').once()
+
+    tuple(
+        module.run_actions(
+            arguments={
+                'global': flexmock(dry_run=False),
+                'repo-create': flexmock(repository='repo'),
+            },
+            config_filename=flexmock(),
+            config={'repositories': []},
+            config_paths=[],
+            local_path=flexmock(),
+            remote_path=flexmock(),
+            local_borg_version=flexmock(),
+            repository={'path': 'repo'},
+        ),
+    )
+
+
+def test_run_actions_with_non_matching_repository_flag_bails():
+    flexmock(module).should_receive('add_custom_log_levels')
+    flexmock(module).should_receive('get_skip_actions').and_return([])
+    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').and_return(
+        False
+    )
+    flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').never()
+    flexmock(module.command).should_receive('Before_after_hooks').never()
+    flexmock(borgmatic.actions.repo_create).should_receive('run_repo_create').never()
+
+    tuple(
+        module.run_actions(
+            arguments={
+                'global': flexmock(dry_run=False),
+                'repo-create': flexmock(repository='other-repo'),
+            },
+            config_filename=flexmock(),
+            config={'repositories': []},
+            config_paths=[],
+            local_path=flexmock(),
+            remote_path=flexmock(),
+            local_borg_version=flexmock(),
+            repository={'path': 'repo'},
+        ),
+    )
+
+
 def test_run_actions_adds_label_file_to_hook_context():
     flexmock(module).should_receive('add_custom_log_levels')
     flexmock(module).should_receive('get_skip_actions').and_return([])
+    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').never()
     flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(
         flexmock(),
     )
@@ -1001,6 +1057,7 @@ def test_run_actions_adds_label_file_to_hook_context():
 def test_run_actions_adds_log_file_to_hook_context():
     flexmock(module).should_receive('add_custom_log_levels')
     flexmock(module).should_receive('get_skip_actions').and_return([])
+    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').never()
     flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(
         flexmock(),
     )
@@ -1037,6 +1094,7 @@ def test_run_actions_adds_log_file_to_hook_context():
 def test_run_actions_runs_transfer():
     flexmock(module).should_receive('add_custom_log_levels')
     flexmock(module).should_receive('get_skip_actions').and_return([])
+    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').never()
     flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(
         flexmock(),
     )
@@ -1060,6 +1118,7 @@ def test_run_actions_runs_transfer():
 def test_run_actions_runs_create():
     flexmock(module).should_receive('add_custom_log_levels')
     flexmock(module).should_receive('get_skip_actions').and_return([])
+    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').never()
     flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(
         flexmock(),
     )
@@ -1085,6 +1144,7 @@ def test_run_actions_runs_create():
 def test_run_actions_with_skip_actions_does_not_run_action_or_action_command_hooks():
     flexmock(module).should_receive('add_custom_log_levels')
     flexmock(module).should_receive('get_skip_actions').and_return(['create'])
+    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').never()
     flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(
         flexmock(),
     )
@@ -1121,6 +1181,7 @@ def test_run_actions_with_skip_actions_does_not_run_action_or_action_command_hoo
 def test_run_actions_runs_recreate():
     flexmock(module).should_receive('add_custom_log_levels')
     flexmock(module).should_receive('get_skip_actions').and_return([])
+    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').never()
     flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(
         flexmock(),
     )
@@ -1145,6 +1206,7 @@ def test_run_actions_runs_recreate():
 def test_run_actions_runs_prune():
     flexmock(module).should_receive('add_custom_log_levels')
     flexmock(module).should_receive('get_skip_actions').and_return([])
+    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').never()
     flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(
         flexmock(),
     )
@@ -1168,6 +1230,7 @@ def test_run_actions_runs_prune():
 def test_run_actions_runs_compact():
     flexmock(module).should_receive('add_custom_log_levels')
     flexmock(module).should_receive('get_skip_actions').and_return([])
+    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').never()
     flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(
         flexmock(),
     )
@@ -1191,6 +1254,7 @@ def test_run_actions_runs_compact():
 def test_run_actions_runs_check_when_repository_enabled_for_checks():
     flexmock(module).should_receive('add_custom_log_levels')
     flexmock(module).should_receive('get_skip_actions').and_return([])
+    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').never()
     flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(
         flexmock(),
     )
@@ -1215,6 +1279,7 @@ def test_run_actions_runs_check_when_repository_enabled_for_checks():
 def test_run_actions_skips_check_when_repository_not_enabled_for_checks():
     flexmock(module).should_receive('add_custom_log_levels')
     flexmock(module).should_receive('get_skip_actions').and_return([])
+    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').never()
     flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(
         flexmock(),
     )
@@ -1239,6 +1304,7 @@ def test_run_actions_skips_check_when_repository_not_enabled_for_checks():
 def test_run_actions_runs_extract():
     flexmock(module).should_receive('add_custom_log_levels')
     flexmock(module).should_receive('get_skip_actions').and_return([])
+    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').never()
     flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(
         flexmock(),
     )
@@ -1262,6 +1328,7 @@ def test_run_actions_runs_extract():
 def test_run_actions_runs_export_tar():
     flexmock(module).should_receive('add_custom_log_levels')
     flexmock(module).should_receive('get_skip_actions').and_return([])
+    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').never()
     flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(
         flexmock(),
     )
@@ -1285,6 +1352,7 @@ def test_run_actions_runs_export_tar():
 def test_run_actions_runs_mount():
     flexmock(module).should_receive('add_custom_log_levels')
     flexmock(module).should_receive('get_skip_actions').and_return([])
+    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').never()
     flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(
         flexmock(),
     )
@@ -1308,6 +1376,7 @@ def test_run_actions_runs_mount():
 def test_run_actions_runs_restore():
     flexmock(module).should_receive('add_custom_log_levels')
     flexmock(module).should_receive('get_skip_actions').and_return([])
+    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').never()
     flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(
         flexmock(),
     )
@@ -1331,6 +1400,7 @@ def test_run_actions_runs_restore():
 def test_run_actions_runs_repo_list():
     flexmock(module).should_receive('add_custom_log_levels')
     flexmock(module).should_receive('get_skip_actions').and_return([])
+    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').never()
     flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(
         flexmock(),
     )
@@ -1356,6 +1426,7 @@ def test_run_actions_runs_repo_list():
 def test_run_actions_runs_list():
     flexmock(module).should_receive('add_custom_log_levels')
     flexmock(module).should_receive('get_skip_actions').and_return([])
+    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').never()
     flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(
         flexmock(),
     )
@@ -1381,6 +1452,7 @@ def test_run_actions_runs_list():
 def test_run_actions_runs_repo_info():
     flexmock(module).should_receive('add_custom_log_levels')
     flexmock(module).should_receive('get_skip_actions').and_return([])
+    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').never()
     flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(
         flexmock(),
     )
@@ -1406,6 +1478,7 @@ def test_run_actions_runs_repo_info():
 def test_run_actions_runs_info():
     flexmock(module).should_receive('add_custom_log_levels')
     flexmock(module).should_receive('get_skip_actions').and_return([])
+    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').never()
     flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(
         flexmock(),
     )
@@ -1431,6 +1504,7 @@ def test_run_actions_runs_info():
 def test_run_actions_runs_break_lock():
     flexmock(module).should_receive('add_custom_log_levels')
     flexmock(module).should_receive('get_skip_actions').and_return([])
+    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').never()
     flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(
         flexmock(),
     )
@@ -1454,6 +1528,7 @@ def test_run_actions_runs_break_lock():
 def test_run_actions_runs_export_key():
     flexmock(module).should_receive('add_custom_log_levels')
     flexmock(module).should_receive('get_skip_actions').and_return([])
+    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').never()
     flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(
         flexmock(),
     )
@@ -1477,6 +1552,7 @@ def test_run_actions_runs_export_key():
 def test_run_actions_runs_import_key():
     flexmock(module).should_receive('add_custom_log_levels')
     flexmock(module).should_receive('get_skip_actions').and_return([])
+    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').never()
     flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(
         flexmock(),
     )
@@ -1500,6 +1576,7 @@ def test_run_actions_runs_import_key():
 def test_run_actions_runs_change_passphrase():
     flexmock(module).should_receive('add_custom_log_levels')
     flexmock(module).should_receive('get_skip_actions').and_return([])
+    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').never()
     flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(
         flexmock(),
     )
@@ -1526,6 +1603,7 @@ def test_run_actions_runs_change_passphrase():
 def test_run_actions_runs_delete():
     flexmock(module).should_receive('add_custom_log_levels')
     flexmock(module).should_receive('get_skip_actions').and_return([])
+    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').never()
     flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(
         flexmock(),
     )
@@ -1549,6 +1627,7 @@ def test_run_actions_runs_delete():
 def test_run_actions_runs_repo_delete():
     flexmock(module).should_receive('add_custom_log_levels')
     flexmock(module).should_receive('get_skip_actions').and_return([])
+    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').never()
     flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(
         flexmock(),
     )
@@ -1575,6 +1654,7 @@ def test_run_actions_runs_repo_delete():
 def test_run_actions_runs_borg():
     flexmock(module).should_receive('add_custom_log_levels')
     flexmock(module).should_receive('get_skip_actions').and_return([])
+    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').never()
     flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(
         flexmock(),
     )
@@ -1598,6 +1678,7 @@ def test_run_actions_runs_borg():
 def test_run_actions_runs_multiple_actions_in_argument_order():
     flexmock(module).should_receive('add_custom_log_levels')
     flexmock(module).should_receive('get_skip_actions').and_return([])
+    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').never()
     flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(
         flexmock(),
     )
@@ -1626,6 +1707,7 @@ def test_run_actions_runs_multiple_actions_in_argument_order():
 def test_run_actions_runs_action_hooks_for_one_action_at_a_time():
     flexmock(module).should_receive('add_custom_log_levels')
     flexmock(module).should_receive('get_skip_actions').and_return([])
+    flexmock(module.borgmatic.config.validate).should_receive('repositories_match').never()
     flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(
         flexmock(),
     )