diff --git a/NEWS b/NEWS index acba5c75..1304c745 100644 --- a/NEWS +++ b/NEWS @@ -10,6 +10,7 @@ with a default port. * #1324: For the MariaDB and MySQL hooks, add "events", "routines", and "tablespaces" options for disabling dumping of scheduled events, stored routines, and tablespaces, respectively. + * #1327: Fix an error from the "diff" action when exclude options are configured. * #1331: Fix the "repo-create" action to more surgically suppress Borg "Repository does not exist" logs and avoid inadvertently suppressing other error logs. * #1333: Fix the "--progress" flag on the "compact" action to actually update the progress of diff --git a/borgmatic/borg/diff.py b/borgmatic/borg/diff.py index 92bcc3d5..886eb1a0 100644 --- a/borgmatic/borg/diff.py +++ b/borgmatic/borg/diff.py @@ -33,7 +33,6 @@ def diff( archive_hostname = config.get('archive_hostname') lock_wait = config.get('lock_wait') - exclude_flags = flags.make_exclude_flags(config) extra_borg_options = config.get('extra_borg_options', {}).get('diff', '') if diff_arguments.only_patterns: @@ -65,7 +64,6 @@ def diff( if patterns_file and diff_arguments.only_patterns else () ) - + exclude_flags + numeric_ids_flags + (('--same-chunker-params',) if diff_arguments.same_chunker_params else ()) + (('--sort-by', ','.join(diff_arguments.sort_keys)) if diff_arguments.sort_keys else ()) diff --git a/tests/unit/borg/test_diff.py b/tests/unit/borg/test_diff.py index a4c73763..b2d832d3 100644 --- a/tests/unit/borg/test_diff.py +++ b/tests/unit/borg/test_diff.py @@ -12,7 +12,6 @@ LOGGING_ANSWER = flexmock() def test_diff_calls_borg_with_archives(): flexmock(module.logging).ANSWER = LOGGING_ANSWER flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels') - flexmock(module.borgmatic.borg.flags).should_receive('make_exclude_flags').and_return(()) flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(None) flexmock(module.borgmatic.borg.pattern).should_receive('write_patterns_file').and_return( flexmock(name='test') @@ -67,7 +66,6 @@ def test_diff_calls_borg_with_archives(): def test_diff_with_local_path_calls_borg_with_it(): flexmock(module.logging).ANSWER = LOGGING_ANSWER flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels') - flexmock(module.borgmatic.borg.flags).should_receive('make_exclude_flags').and_return(()) flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(None) flexmock(module.borgmatic.borg.pattern).should_receive('write_patterns_file').and_return( flexmock(name='test') @@ -122,7 +120,6 @@ def test_diff_with_local_path_calls_borg_with_it(): def test_diff_with_archive_hostname_calls_borg_with_it(): flexmock(module.logging).ANSWER = LOGGING_ANSWER flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels') - flexmock(module.borgmatic.borg.flags).should_receive('make_exclude_flags').and_return(()) flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(None) flexmock(module.borgmatic.borg.pattern).should_receive('write_patterns_file').and_return( flexmock(name='test') @@ -178,7 +175,6 @@ def test_diff_with_archive_hostname_calls_borg_with_it(): def test_diff_with_remote_path_calls_borg_with_it(): flexmock(module.logging).ANSWER = LOGGING_ANSWER flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels') - flexmock(module.borgmatic.borg.flags).should_receive('make_exclude_flags').and_return(()) flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(None) flexmock(module.borgmatic.borg.pattern).should_receive('write_patterns_file').and_return( flexmock(name='test') @@ -235,7 +231,6 @@ def test_diff_with_remote_path_calls_borg_with_it(): def test_diff_with_lock_wait_calls_borg_with_it(): flexmock(module.logging).ANSWER = LOGGING_ANSWER flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels') - flexmock(module.borgmatic.borg.flags).should_receive('make_exclude_flags').and_return(()) flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(None) flexmock(module.borgmatic.borg.pattern).should_receive('write_patterns_file').and_return( flexmock(name='test') @@ -292,7 +287,6 @@ def test_diff_with_lock_wait_calls_borg_with_it(): def test_diff_with_log_level_info_calls_borg_with_info_flag(): flexmock(module.logging).ANSWER = LOGGING_ANSWER flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels') - flexmock(module.borgmatic.borg.flags).should_receive('make_exclude_flags').and_return(()) flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(None) flexmock(module.borgmatic.borg.pattern).should_receive('write_patterns_file').and_return( flexmock(name='test') @@ -349,7 +343,6 @@ def test_diff_with_log_level_info_calls_borg_with_info_flag(): def test_diff_with_log_level_debug_calls_borg_with_debug_flags(): flexmock(module.logging).ANSWER = LOGGING_ANSWER flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels') - flexmock(module.borgmatic.borg.flags).should_receive('make_exclude_flags').and_return(()) flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(None) flexmock(module.borgmatic.borg.pattern).should_receive('write_patterns_file').and_return( flexmock(name='test') @@ -407,7 +400,6 @@ def test_diff_with_log_level_debug_calls_borg_with_debug_flags(): def test_diff_with_only_patterns_calls_borg_with_configured_pattern_paths(): flexmock(module.logging).ANSWER = LOGGING_ANSWER flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels') - flexmock(module.borgmatic.borg.flags).should_receive('make_exclude_flags').and_return(()) flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(None) flexmock(module.borgmatic.borg.feature).should_receive('available').and_return(True) flexmock(module.borgmatic.borg.flags).should_receive('make_repository_flags').and_return( @@ -462,69 +454,9 @@ def test_diff_with_only_patterns_calls_borg_with_configured_pattern_paths(): ) -def test_diff_with_exclude_config_calls_borg_with_exclude_flags(): - flexmock(module.logging).ANSWER = LOGGING_ANSWER - flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels') - flexmock(module.borgmatic.borg.flags).should_receive('make_exclude_flags').and_return( - ('--exclude', 'stuff') - ) - flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(None) - flexmock(module.borgmatic.borg.pattern).should_receive('write_patterns_file').and_return( - flexmock(name='test') - ) - flexmock(module.borgmatic.borg.feature).should_receive('available').and_return(True) - flexmock(module.borgmatic.borg.flags).should_receive('make_repository_flags').and_return( - ('--repo', 'repo') - ) - flexmock(module.borgmatic.borg.flags).should_receive('make_repository_archive_flags').never() - environment = flexmock() - flexmock(module.borgmatic.borg.environment).should_receive('make_environment').and_return( - environment - ) - flexmock(module.borgmatic.execute).should_receive('execute_command').with_args( - full_command=( - 'borg', - 'diff', - '--log-json', - '--exclude', - 'stuff', - '--repo', - 'repo', - 'archive', - 'archive2', - ), - output_log_level=LOGGING_ANSWER, - environment=environment, - working_directory=None, - borg_local_path='borg', - borg_exit_codes=None, - ).once() - insert_logging_mock(logging.WARNING) - - module.borgmatic.borg.diff.diff( - repository='repo', - archive='archive', - second_archive='archive2', - config={}, - local_borg_version=None, - diff_arguments=flexmock( - same_chunker_params=False, - sort_keys=[], - content_only=False, - second_archive='archive2', - only_patterns=False, - ), - global_arguments=flexmock(), - local_path='borg', - remote_path=None, - patterns=[], - ) - - def test_diff_with_numeric_ids_calls_borg_with_numeric_ids_flag(): flexmock(module.logging).ANSWER = LOGGING_ANSWER flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels') - flexmock(module.borgmatic.borg.flags).should_receive('make_exclude_flags').and_return(()) flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(None) flexmock(module.borgmatic.borg.pattern).should_receive('write_patterns_file').and_return( flexmock(name='test') @@ -580,7 +512,6 @@ def test_diff_with_numeric_ids_calls_borg_with_numeric_ids_flag(): def test_diff_with_numeric_ids_and_feature_not_available_calls_borg_with_numeric_owner_flag(): flexmock(module.logging).ANSWER = LOGGING_ANSWER flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels') - flexmock(module.borgmatic.borg.flags).should_receive('make_exclude_flags').and_return(()) flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(None) flexmock(module.borgmatic.borg.pattern).should_receive('write_patterns_file').and_return( flexmock(name='test') @@ -641,7 +572,6 @@ def test_diff_with_numeric_ids_and_feature_not_available_calls_borg_with_numeric def test_diff_with_same_chunker_params_calls_borg_with_it(): flexmock(module.logging).ANSWER = LOGGING_ANSWER flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels') - flexmock(module.borgmatic.borg.flags).should_receive('make_exclude_flags').and_return(()) flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(None) flexmock(module.borgmatic.borg.pattern).should_receive('write_patterns_file').and_return( flexmock(name='test') @@ -697,7 +627,6 @@ def test_diff_with_same_chunker_params_calls_borg_with_it(): def test_diff_with_sort_keys_calls_borg_with_formatted_sort_by_flags(): flexmock(module.logging).ANSWER = LOGGING_ANSWER flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels') - flexmock(module.borgmatic.borg.flags).should_receive('make_exclude_flags').and_return(()) flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(None) flexmock(module.borgmatic.borg.pattern).should_receive('write_patterns_file').and_return( flexmock(name='test') @@ -754,7 +683,6 @@ def test_diff_with_sort_keys_calls_borg_with_formatted_sort_by_flags(): def test_diff_with_content_only_calls_borg_with_it(): flexmock(module.logging).ANSWER = LOGGING_ANSWER flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels') - flexmock(module.borgmatic.borg.flags).should_receive('make_exclude_flags').and_return(()) flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(None) flexmock(module.borgmatic.borg.pattern).should_receive('write_patterns_file').and_return( flexmock(name='test') @@ -810,7 +738,6 @@ def test_diff_with_content_only_calls_borg_with_it(): def test_diff_with_extra_borg_options_calls_borg_with_them(): flexmock(module.logging).ANSWER = LOGGING_ANSWER flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels') - flexmock(module.borgmatic.borg.flags).should_receive('make_exclude_flags').and_return(()) flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(None) flexmock(module.borgmatic.borg.pattern).should_receive('write_patterns_file').and_return( flexmock(name='test') @@ -867,7 +794,6 @@ def test_diff_with_extra_borg_options_calls_borg_with_them(): def test_diff_without_separate_repository_archive_feature_available_calls_borg_joined_repository_archive(): flexmock(module.logging).ANSWER = LOGGING_ANSWER flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels') - flexmock(module.borgmatic.borg.flags).should_receive('make_exclude_flags').and_return(()) flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(None) flexmock(module.borgmatic.borg.pattern).should_receive('write_patterns_file').and_return( flexmock(name='test')