ソースを参照

Fix root patterns so they don't have an invalid "sh:" prefix before getting passed to Borg (#979).

Dan Helfman 4 ヶ月 前
コミット
4c35a564ef
3 ファイル変更8 行追加17 行削除
  1. 1 0
      NEWS
  2. 2 2
      borgmatic/actions/create.py
  3. 5 15
      tests/unit/actions/test_create.py

+ 1 - 0
NEWS

@@ -1,4 +1,5 @@
 1.9.8.dev0
 1.9.8.dev0
+ * #979: Fix root patterns so they don't have an invalid "sh:" prefix before getting passed to Borg.
  * Expand the recent contributors documentation section to include ticket submitters—not just code
  * Expand the recent contributors documentation section to include ticket submitters—not just code
    contributors—because there are multiple ways to contribute to the project! See:
    contributors—because there are multiple ways to contribute to the project! See:
    https://torsion.org/borgmatic/#recent-contributors
    https://torsion.org/borgmatic/#recent-contributors

+ 2 - 2
borgmatic/actions/create.py

@@ -55,7 +55,7 @@ def collect_patterns(config):
                 for source_directory in config.get('source_directories', ())
                 for source_directory in config.get('source_directories', ())
             )
             )
             + tuple(
             + tuple(
-                parse_pattern(pattern_line.strip(), borgmatic.borg.pattern.Pattern_style.SHELL)
+                parse_pattern(pattern_line.strip())
                 for pattern_line in config.get('patterns', ())
                 for pattern_line in config.get('patterns', ())
                 if not pattern_line.lstrip().startswith('#')
                 if not pattern_line.lstrip().startswith('#')
                 if pattern_line.strip()
                 if pattern_line.strip()
@@ -68,7 +68,7 @@ def collect_patterns(config):
                 for exclude_line in config.get('exclude_patterns', ())
                 for exclude_line in config.get('exclude_patterns', ())
             )
             )
             + tuple(
             + tuple(
-                parse_pattern(pattern_line.strip(), borgmatic.borg.pattern.Pattern_style.SHELL)
+                parse_pattern(pattern_line.strip())
                 for filename in config.get('patterns_from', ())
                 for filename in config.get('patterns_from', ())
                 for pattern_line in open(filename).readlines()
                 for pattern_line in open(filename).readlines()
                 if not pattern_line.lstrip().startswith('#')
                 if not pattern_line.lstrip().startswith('#')

+ 5 - 15
tests/unit/actions/test_create.py

@@ -34,15 +34,11 @@ def test_collect_patterns_converts_source_directories():
 
 
 
 
 def test_collect_patterns_parses_config_patterns():
 def test_collect_patterns_parses_config_patterns():
-    flexmock(module).should_receive('parse_pattern').with_args(
-        'R /foo', Pattern_style.SHELL
-    ).and_return(Pattern('/foo'))
+    flexmock(module).should_receive('parse_pattern').with_args('R /foo').and_return(Pattern('/foo'))
     flexmock(module).should_receive('parse_pattern').with_args('# comment').never()
     flexmock(module).should_receive('parse_pattern').with_args('# comment').never()
     flexmock(module).should_receive('parse_pattern').with_args('').never()
     flexmock(module).should_receive('parse_pattern').with_args('').never()
     flexmock(module).should_receive('parse_pattern').with_args('   ').never()
     flexmock(module).should_receive('parse_pattern').with_args('   ').never()
-    flexmock(module).should_receive('parse_pattern').with_args(
-        'R /bar', Pattern_style.SHELL
-    ).and_return(Pattern('/bar'))
+    flexmock(module).should_receive('parse_pattern').with_args('R /bar').and_return(Pattern('/bar'))
 
 
     assert module.collect_patterns({'patterns': ['R /foo', '# comment', '', '   ', 'R /bar']}) == (
     assert module.collect_patterns({'patterns': ['R /foo', '# comment', '', '   ', 'R /bar']}) == (
         Pattern('/foo'),
         Pattern('/foo'),
@@ -64,18 +60,12 @@ def test_collect_patterns_reads_config_patterns_from_file():
     builtins.should_receive('open').with_args('file2.txt').and_return(
     builtins.should_receive('open').with_args('file2.txt').and_return(
         io.StringIO('R /bar\n# comment\n\n   \nR /baz')
         io.StringIO('R /bar\n# comment\n\n   \nR /baz')
     )
     )
-    flexmock(module).should_receive('parse_pattern').with_args(
-        'R /foo', Pattern_style.SHELL
-    ).and_return(Pattern('/foo'))
+    flexmock(module).should_receive('parse_pattern').with_args('R /foo').and_return(Pattern('/foo'))
     flexmock(module).should_receive('parse_pattern').with_args('# comment').never()
     flexmock(module).should_receive('parse_pattern').with_args('# comment').never()
     flexmock(module).should_receive('parse_pattern').with_args('').never()
     flexmock(module).should_receive('parse_pattern').with_args('').never()
     flexmock(module).should_receive('parse_pattern').with_args('   ').never()
     flexmock(module).should_receive('parse_pattern').with_args('   ').never()
-    flexmock(module).should_receive('parse_pattern').with_args(
-        'R /bar', Pattern_style.SHELL
-    ).and_return(Pattern('/bar'))
-    flexmock(module).should_receive('parse_pattern').with_args(
-        'R /baz', Pattern_style.SHELL
-    ).and_return(Pattern('/baz'))
+    flexmock(module).should_receive('parse_pattern').with_args('R /bar').and_return(Pattern('/bar'))
+    flexmock(module).should_receive('parse_pattern').with_args('R /baz').and_return(Pattern('/baz'))
 
 
     assert module.collect_patterns({'patterns_from': ['file1.txt', 'file2.txt']}) == (
     assert module.collect_patterns({'patterns_from': ['file1.txt', 'file2.txt']}) == (
         Pattern('/foo'),
         Pattern('/foo'),