diff --git a/borgmatic/borg/list.py b/borgmatic/borg/list.py index fadc5055d..cbca8d7c7 100644 --- a/borgmatic/borg/list.py +++ b/borgmatic/borg/list.py @@ -117,9 +117,14 @@ def list_archive( for flag_name in ('prefix', 'glob-archives', 'sort-by', 'first', 'last'): if getattr(list_arguments, flag_name.replace('-', '_'), None): raise ValueError( - f'The --{flag_name} flag on the list action is not supported when using the --archive flag and Borg 2.x.' + f'The --{flag_name} flag on the list action is not supported when using the --archive/--find flags and Borg 2.x.' ) + if list_arguments.json: + raise ValueError( + 'The --json flag on the list action is not supported when using the --archive/--find flags.' + ) + borg_environment = environment.make_environment(storage_config) # If there are any paths to find (and there's not a single archive already selected), start by @@ -173,12 +178,9 @@ def list_archive( remote_path, ) + make_find_paths(list_arguments.find_paths) - output = execute_command( + execute_command( main_command, - output_log_level=None if list_arguments.json else logging.WARNING, + output_log_level=logging.WARNING, borg_local_path=local_path, extra_environment=borg_environment, ) - - if list_arguments.json: - return output diff --git a/borgmatic/commands/arguments.py b/borgmatic/commands/arguments.py index 02180def7..8a2ed346f 100644 --- a/borgmatic/commands/arguments.py +++ b/borgmatic/commands/arguments.py @@ -626,7 +626,7 @@ def make_parsers(): '--successful', default=True, action='store_true', - help='Deprecated; no effect. Newer versions of Borg list successful (non-checkpoint) archives by default.', + help='Deprecated; no effect. Newer versions of Borg shows successful (non-checkpoint) archives by default.', ) list_group.add_argument( '--sort-by', metavar='KEYS', help='Comma-separated list of sorting keys' diff --git a/tests/unit/borg/test_list.py b/tests/unit/borg/test_list.py index 7111cb61a..d1c5d397b 100644 --- a/tests/unit/borg/test_list.py +++ b/tests/unit/borg/test_list.py @@ -282,33 +282,18 @@ def test_list_archive_calls_borg_with_parameters(): ) -def test_list_archive_with_json_suppresses_most_borg_output(): +def test_list_archive_with_archive_and_json_errors(): list_arguments = argparse.Namespace(archive='archive', paths=None, json=True, find_paths=None) flexmock(module.feature).should_receive('available').and_return(False) - flexmock(module).should_receive('make_list_command').with_args( - repository='repo', - storage_config={}, - local_borg_version='1.2.3', - list_arguments=list_arguments, - local_path='borg', - remote_path=None, - ).and_return(('borg', 'list', 'repo::archive')) - flexmock(module).should_receive('make_find_paths').and_return(()) - flexmock(module.environment).should_receive('make_environment') - flexmock(module).should_receive('execute_command').with_args( - ('borg', 'list', 'repo::archive'), - output_log_level=None, - borg_local_path='borg', - extra_environment=None, - ).once() - module.list_archive( - repository='repo', - storage_config={}, - local_borg_version='1.2.3', - list_arguments=list_arguments, - ) + with pytest.raises(ValueError): + module.list_archive( + repository='repo', + storage_config={}, + local_borg_version='1.2.3', + list_arguments=list_arguments, + ) def test_list_archive_calls_borg_with_local_path():