diff --git a/NEWS b/NEWS index 6e022110..0b75aa30 100644 --- a/NEWS +++ b/NEWS @@ -1,8 +1,8 @@ 1.4.23.dev0 * #274: Add ~/.config/borgmatic.d as another configuration directory default. * #277: Customize Healthchecks log level via borgmatic "--monitoring-verbosity" flag. - * For "create" and "prune" actions, no longer list files or show detailed stats at verbosity 1. You - can opt back in with "--files" or "--stats" flags. + * For "create" and "prune" actions, no longer list files or show detailed stats at any verbosities + by default. You can opt back in with "--files" or "--stats" flags. 1.4.22 * #276, #285: Disable colored output when "--json" flag is used, so as to produce valid JSON ouput. diff --git a/borgmatic/borg/create.py b/borgmatic/borg/create.py index 5258e9d9..cfbd7b6d 100644 --- a/borgmatic/borg/create.py +++ b/borgmatic/borg/create.py @@ -176,17 +176,9 @@ def create_archive( + (('--remote-path', remote_path) if remote_path else ()) + (('--umask', str(umask)) if umask else ()) + (('--lock-wait', str(lock_wait)) if lock_wait else ()) - + ( - ('--list', '--filter', 'AME-') - if (files or logger.isEnabledFor(logging.DEBUG)) and not json and not progress - else () - ) + + (('--list', '--filter', 'AME-') if files and not json and not progress else ()) + (('--info',) if logger.getEffectiveLevel() == logging.INFO and not json else ()) - + ( - ('--stats',) - if (stats or logger.isEnabledFor(logging.DEBUG)) and not json and not dry_run - else () - ) + + (('--stats',) if stats and not json and not dry_run else ()) + (('--debug', '--show-rc') if logger.isEnabledFor(logging.DEBUG) and not json else ()) + (('--dry-run',) if dry_run else ()) + (('--progress',) if progress else ()) diff --git a/borgmatic/borg/prune.py b/borgmatic/borg/prune.py index 492ff9b6..83e421d2 100644 --- a/borgmatic/borg/prune.py +++ b/borgmatic/borg/prune.py @@ -58,9 +58,9 @@ def prune_archives( + (('--remote-path', remote_path) if remote_path else ()) + (('--umask', str(umask)) if umask else ()) + (('--lock-wait', str(lock_wait)) if lock_wait else ()) - + (('--stats',) if (stats or logger.isEnabledFor(logging.DEBUG)) and not dry_run else ()) + + (('--stats',) if stats and not dry_run else ()) + (('--info',) if logger.getEffectiveLevel() == logging.INFO else ()) - + (('--list',) if files or logger.isEnabledFor(logging.DEBUG) else ()) + + (('--list',) if files else ()) + (('--debug', '--show-rc') if logger.isEnabledFor(logging.DEBUG) else ()) + (('--dry-run',) if dry_run else ()) + (tuple(extra_borg_options.split(' ')) if extra_borg_options else ()) diff --git a/tests/unit/borg/test_create.py b/tests/unit/borg/test_create.py index 79cdfcab..5e51a51e 100644 --- a/tests/unit/borg/test_create.py +++ b/tests/unit/borg/test_create.py @@ -349,8 +349,7 @@ def test_create_archive_with_log_debug_calls_borg_with_debug_parameter(): flexmock(module).should_receive('_make_pattern_flags').and_return(()) flexmock(module).should_receive('_make_exclude_flags').and_return(()) flexmock(module).should_receive('execute_command').with_args( - ('borg', 'create', '--list', '--filter', 'AME-', '--stats', '--debug', '--show-rc') - + ARCHIVE_WITH_PATHS, + ('borg', 'create', '--debug', '--show-rc') + ARCHIVE_WITH_PATHS, output_log_level=logging.INFO, error_on_warnings=False, ) @@ -421,7 +420,7 @@ def test_create_archive_with_dry_run_calls_borg_with_dry_run_parameter(): ) -def test_create_archive_with_dry_run_and_log_info_calls_borg_without_stats_parameter(): +def test_create_archive_with_stats_and_dry_run_calls_borg_without_stats_parameter(): # --dry-run and --stats are mutually exclusive, see: # https://borgbackup.readthedocs.io/en/stable/usage/create.html#description flexmock(module).should_receive('borgmatic_source_directories').and_return([]) @@ -447,36 +446,7 @@ def test_create_archive_with_dry_run_and_log_info_calls_borg_without_stats_param 'exclude_patterns': None, }, storage_config={}, - ) - - -def test_create_archive_with_dry_run_and_log_debug_calls_borg_without_stats_parameter(): - # --dry-run and --stats are mutually exclusive, see: - # https://borgbackup.readthedocs.io/en/stable/usage/create.html#description - flexmock(module).should_receive('borgmatic_source_directories').and_return([]) - flexmock(module).should_receive('_expand_directories').and_return(('foo', 'bar')) - flexmock(module).should_receive('_expand_home_directories').and_return(()) - flexmock(module).should_receive('_write_pattern_file').and_return(None) - flexmock(module).should_receive('_make_pattern_flags').and_return(()) - flexmock(module).should_receive('_make_pattern_flags').and_return(()) - flexmock(module).should_receive('_make_exclude_flags').and_return(()) - flexmock(module).should_receive('execute_command').with_args( - ('borg', 'create', '--list', '--filter', 'AME-', '--debug', '--show-rc', '--dry-run') - + ARCHIVE_WITH_PATHS, - output_log_level=logging.INFO, - error_on_warnings=False, - ) - insert_logging_mock(logging.DEBUG) - - module.create_archive( - dry_run=True, - repository='repo', - location_config={ - 'source_directories': ['foo', 'bar'], - 'repositories': ['repo'], - 'exclude_patterns': None, - }, - storage_config={}, + stats=True, ) diff --git a/tests/unit/borg/test_prune.py b/tests/unit/borg/test_prune.py index a61c4908..b1ff0132 100644 --- a/tests/unit/borg/test_prune.py +++ b/tests/unit/borg/test_prune.py @@ -88,9 +88,7 @@ def test_prune_archives_with_log_debug_calls_borg_with_debug_parameter(): flexmock(module).should_receive('_make_prune_flags').with_args(retention_config).and_return( BASE_PRUNE_FLAGS ) - insert_execute_command_mock( - PRUNE_COMMAND + ('--stats', '--list', '--debug', '--show-rc', 'repo'), logging.INFO - ) + insert_execute_command_mock(PRUNE_COMMAND + ('--debug', '--show-rc', 'repo'), logging.INFO) insert_logging_mock(logging.DEBUG) module.prune_archives(