diff --git a/NEWS b/NEWS index c27eea98..0033b26f 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,7 @@ 1.9.7.dev0 * #968: Fix for a "spot" check error when a filename in the most recent archive contains a newline. * #970: Fix for an error when there's a blank line in the configured patterns or excludes. + * #971: Fix for "exclude_from" files being completely ignored. 1.9.6 * #959: Fix an error in the Btrfs hook when a subvolume mounted at "/" is configured in borgmatic's diff --git a/borgmatic/actions/create.py b/borgmatic/actions/create.py index d0d88385..126f791d 100644 --- a/borgmatic/actions/create.py +++ b/borgmatic/actions/create.py @@ -80,7 +80,7 @@ def collect_patterns(config): borgmatic.borg.pattern.Pattern_type.EXCLUDE, borgmatic.borg.pattern.Pattern_style.FNMATCH, ) - for filename in config.get('excludes_from', ()) + for filename in config.get('exclude_from', ()) for exclude_line in open(filename).readlines() if not exclude_line.lstrip().startswith('#') if exclude_line.strip() @@ -89,7 +89,7 @@ def collect_patterns(config): except (FileNotFoundError, OSError) as error: logger.debug(error) - raise ValueError(f'Cannot read patterns_from/excludes_from file: {error.filename}') + raise ValueError(f'Cannot read patterns_from/exclude_from file: {error.filename}') def expand_directory(directory, working_directory): diff --git a/tests/unit/actions/test_create.py b/tests/unit/actions/test_create.py index 4c5ecf80..523e3dbc 100644 --- a/tests/unit/actions/test_create.py +++ b/tests/unit/actions/test_create.py @@ -82,7 +82,7 @@ def test_collect_patterns_errors_on_missing_config_patterns_from_file(): module.collect_patterns({'patterns_from': ['file1.txt', 'file2.txt']}) -def test_collect_patterns_reads_config_excludes_from_file(): +def test_collect_patterns_reads_config_exclude_from_file(): builtins = flexmock(sys.modules['builtins']) builtins.should_receive('open').with_args('file1.txt').and_return(io.StringIO('/foo')) builtins.should_receive('open').with_args('file2.txt').and_return( @@ -94,20 +94,20 @@ def test_collect_patterns_reads_config_excludes_from_file(): flexmock(module).should_receive('parse_pattern').with_args(' ').never() flexmock(module).should_receive('parse_pattern').with_args('/baz').and_return(Pattern('/baz')) - assert module.collect_patterns({'excludes_from': ['file1.txt', 'file2.txt']}) == ( + assert module.collect_patterns({'exclude_from': ['file1.txt', 'file2.txt']}) == ( Pattern('/foo', Pattern_type.EXCLUDE, Pattern_style.FNMATCH), Pattern('/bar', Pattern_type.EXCLUDE, Pattern_style.FNMATCH), Pattern('/baz', Pattern_type.EXCLUDE, Pattern_style.FNMATCH), ) -def test_collect_patterns_errors_on_missing_config_excludes_from_file(): +def test_collect_patterns_errors_on_missing_config_exclude_from_file(): builtins = flexmock(sys.modules['builtins']) builtins.should_receive('open').with_args('file1.txt').and_raise(OSError) flexmock(module).should_receive('parse_pattern').never() with pytest.raises(ValueError): - module.collect_patterns({'excludes_from': ['file1.txt', 'file2.txt']}) + module.collect_patterns({'exclude_from': ['file1.txt', 'file2.txt']}) def test_expand_directory_with_basic_path_passes_it_through():