Jelajahi Sumber

Pass --show-rc option to Borg when at highest verbosity level (#89).

Dan Helfman 6 tahun lalu
induk
melakukan
7d40a448cb

+ 1 - 0
NEWS

@@ -3,6 +3,7 @@
    borgmatic's storage configuration.
    borgmatic's storage configuration.
  * #88: Fix declared pykwalify compatibility version range in setup.py to prevent use of ancient
  * #88: Fix declared pykwalify compatibility version range in setup.py to prevent use of ancient
    versions of pykwalify with large version numbers.
    versions of pykwalify with large version numbers.
+ * #89: Pass --show-rc option to Borg when at highest verbosity level.
 
 
 1.2.2
 1.2.2
  * #85: Fix compatibility issue between pykwalify and ruamel.yaml 0.15.52, which manifested in
  * #85: Fix compatibility issue between pykwalify and ruamel.yaml 0.15.52, which manifested in

+ 1 - 1
borgmatic/borg/check.py

@@ -93,7 +93,7 @@ def check_archives(verbosity, repository, storage_config, consistency_config, lo
         lock_wait_flags = ('--lock-wait', str(lock_wait)) if lock_wait else ()
         lock_wait_flags = ('--lock-wait', str(lock_wait)) if lock_wait else ()
         verbosity_flags = {
         verbosity_flags = {
             VERBOSITY_SOME: ('--info',),
             VERBOSITY_SOME: ('--info',),
-            VERBOSITY_LOTS: ('--debug',),
+            VERBOSITY_LOTS: ('--debug', '--show-rc'),
         }.get(verbosity, ())
         }.get(verbosity, ())
         prefix = consistency_config.get('prefix')
         prefix = consistency_config.get('prefix')
 
 

+ 2 - 2
borgmatic/borg/create.py

@@ -151,8 +151,8 @@ def create_archive(
         + (('--umask', str(umask)) if umask else ())
         + (('--umask', str(umask)) if umask else ())
         + (('--lock-wait', str(lock_wait)) if lock_wait else ())
         + (('--lock-wait', str(lock_wait)) if lock_wait else ())
         + {
         + {
-            VERBOSITY_SOME: ('--info',) if dry_run else ('--info', '--stats',),
-            VERBOSITY_LOTS: ('--debug', '--list',) if dry_run else ('--debug', '--list', '--stats',),
+            VERBOSITY_SOME: ('--info',) if dry_run else ('--info', '--stats'),
+            VERBOSITY_LOTS: ('--debug', '--list', '--show-rc') if dry_run else ('--debug', '--list', '--show-rc', '--stats'),
         }.get(verbosity, ())
         }.get(verbosity, ())
         + (('--dry-run',) if dry_run else ())
         + (('--dry-run',) if dry_run else ())
     )
     )

+ 1 - 1
borgmatic/borg/extract.py

@@ -17,7 +17,7 @@ def extract_last_archive_dry_run(verbosity, repository, lock_wait=None, local_pa
     lock_wait_flags = ('--lock-wait', str(lock_wait)) if lock_wait else ()
     lock_wait_flags = ('--lock-wait', str(lock_wait)) if lock_wait else ()
     verbosity_flags = {
     verbosity_flags = {
         VERBOSITY_SOME: ('--info',),
         VERBOSITY_SOME: ('--info',),
-        VERBOSITY_LOTS: ('--debug',),
+        VERBOSITY_LOTS: ('--debug', '--show-rc'),
     }.get(verbosity, ())
     }.get(verbosity, ())
 
 
     full_list_command = (
     full_list_command = (

+ 1 - 1
borgmatic/borg/info.py

@@ -23,7 +23,7 @@ def display_archives_info(
         + (('--json',) if json else ())
         + (('--json',) if json else ())
         + {
         + {
             VERBOSITY_SOME: ('--info',),
             VERBOSITY_SOME: ('--info',),
-            VERBOSITY_LOTS: ('--debug',),
+            VERBOSITY_LOTS: ('--debug', '--show-rc'),
         }.get(verbosity, ())
         }.get(verbosity, ())
     )
     )
 
 

+ 1 - 1
borgmatic/borg/list.py

@@ -23,7 +23,7 @@ def list_archives(
         + (('--json',) if json else ())
         + (('--json',) if json else ())
         + {
         + {
             VERBOSITY_SOME: ('--info',),
             VERBOSITY_SOME: ('--info',),
-            VERBOSITY_LOTS: ('--debug',),
+            VERBOSITY_LOTS: ('--debug', '--show-rc'),
         }.get(verbosity, ())
         }.get(verbosity, ())
     )
     )
 
 

+ 1 - 1
borgmatic/borg/prune.py

@@ -56,7 +56,7 @@ def prune_archives(verbosity, dry_run, repository, storage_config, retention_con
         + (('--lock-wait', str(lock_wait)) if lock_wait else ())
         + (('--lock-wait', str(lock_wait)) if lock_wait else ())
         + {
         + {
             VERBOSITY_SOME: ('--info', '--stats',),
             VERBOSITY_SOME: ('--info', '--stats',),
-            VERBOSITY_LOTS: ('--debug', '--stats', '--list'),
+            VERBOSITY_LOTS: ('--debug', '--stats', '--list', '--show-rc'),
         }.get(verbosity, ())
         }.get(verbosity, ())
         + (('--dry-run',) if dry_run else ())
         + (('--dry-run',) if dry_run else ())
     )
     )

+ 1 - 1
borgmatic/tests/unit/borg/test_check.py

@@ -173,7 +173,7 @@ def test_check_archives_with_verbosity_lots_calls_borg_with_debug_parameter():
     flexmock(module).should_receive('_parse_checks').and_return(checks)
     flexmock(module).should_receive('_parse_checks').and_return(checks)
     flexmock(module).should_receive('_make_check_flags').and_return(())
     flexmock(module).should_receive('_make_check_flags').and_return(())
     insert_subprocess_mock(
     insert_subprocess_mock(
-        ('borg', 'check', 'repo', '--debug'),
+        ('borg', 'check', 'repo', '--debug', '--show-rc'),
         stdout=None, stderr=STDOUT,
         stdout=None, stderr=STDOUT,
     )
     )
 
 

+ 2 - 2
borgmatic/tests/unit/borg/test_create.py

@@ -296,7 +296,7 @@ def test_create_archive_with_verbosity_lots_calls_borg_with_debug_parameter():
     flexmock(module).should_receive('_write_pattern_file').and_return(None)
     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('_make_exclude_flags').and_return(())
-    insert_subprocess_mock(CREATE_COMMAND + ('--debug', '--list', '--stats'))
+    insert_subprocess_mock(CREATE_COMMAND + ('--debug', '--list', '--show-rc', '--stats'))
 
 
     module.create_archive(
     module.create_archive(
         verbosity=VERBOSITY_LOTS,
         verbosity=VERBOSITY_LOTS,
@@ -359,7 +359,7 @@ def test_create_archive_with_dry_run_and_verbosity_lots_calls_borg_without_stats
     flexmock(module).should_receive('_make_pattern_flags').and_return(())
     flexmock(module).should_receive('_make_pattern_flags').and_return(())
     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('_make_exclude_flags').and_return(())
-    insert_subprocess_mock(CREATE_COMMAND + ('--debug', '--list', '--dry-run'))
+    insert_subprocess_mock(CREATE_COMMAND + ('--debug', '--list', '--show-rc', '--dry-run'))
 
 
     module.create_archive(
     module.create_archive(
         verbosity=VERBOSITY_LOTS,
         verbosity=VERBOSITY_LOTS,

+ 2 - 2
borgmatic/tests/unit/borg/test_extract.py

@@ -73,11 +73,11 @@ def test_extract_last_archive_dry_run_with_verbosity_some_should_call_borg_with_
 def test_extract_last_archive_dry_run_with_verbosity_lots_should_call_borg_with_debug_parameter():
 def test_extract_last_archive_dry_run_with_verbosity_lots_should_call_borg_with_debug_parameter():
     flexmock(sys.stdout).encoding = 'utf-8'
     flexmock(sys.stdout).encoding = 'utf-8'
     insert_subprocess_check_output_mock(
     insert_subprocess_check_output_mock(
-        ('borg', 'list', '--short', 'repo', '--debug'),
+        ('borg', 'list', '--short', 'repo', '--debug', '--show-rc'),
         result='archive1\narchive2\n'.encode('utf-8'),
         result='archive1\narchive2\n'.encode('utf-8'),
     )
     )
     insert_subprocess_mock(
     insert_subprocess_mock(
-        ('borg', 'extract', '--dry-run', 'repo::archive2', '--debug', '--list'),
+        ('borg', 'extract', '--dry-run', 'repo::archive2', '--debug', '--show-rc', '--list'),
     )
     )
 
 
     module.extract_last_archive_dry_run(
     module.extract_last_archive_dry_run(

+ 1 - 1
borgmatic/tests/unit/borg/test_info.py

@@ -35,7 +35,7 @@ def test_display_archives_info_with_verbosity_some_calls_borg_with_info_paramete
 
 
 
 
 def test_display_archives_info_with_verbosity_lots_calls_borg_with_debug_parameter():
 def test_display_archives_info_with_verbosity_lots_calls_borg_with_debug_parameter():
-    insert_subprocess_mock(INFO_COMMAND + ('--debug',))
+    insert_subprocess_mock(INFO_COMMAND + ('--debug', '--show-rc'))
 
 
     module.display_archives_info(
     module.display_archives_info(
         repository='repo',
         repository='repo',

+ 1 - 1
borgmatic/tests/unit/borg/test_list.py

@@ -35,7 +35,7 @@ def test_list_archives_with_verbosity_some_calls_borg_with_info_parameter():
 
 
 
 
 def test_list_archives_with_verbosity_lots_calls_borg_with_debug_parameter():
 def test_list_archives_with_verbosity_lots_calls_borg_with_debug_parameter():
-    insert_subprocess_mock(LIST_COMMAND + ('--debug',))
+    insert_subprocess_mock(LIST_COMMAND + ('--debug', '--show-rc'))
 
 
     module.list_archives(
     module.list_archives(
         repository='repo',
         repository='repo',

+ 1 - 1
borgmatic/tests/unit/borg/test_prune.py

@@ -92,7 +92,7 @@ def test_prune_archives_with_verbosity_lots_calls_borg_with_debug_parameter():
     flexmock(module).should_receive('_make_prune_flags').with_args(retention_config).and_return(
     flexmock(module).should_receive('_make_prune_flags').with_args(retention_config).and_return(
         BASE_PRUNE_FLAGS,
         BASE_PRUNE_FLAGS,
     )
     )
-    insert_subprocess_mock(PRUNE_COMMAND + ('--debug', '--stats', '--list'))
+    insert_subprocess_mock(PRUNE_COMMAND + ('--debug', '--stats', '--list', '--show-rc'))
 
 
     module.prune_archives(
     module.prune_archives(
         repository='repo',
         repository='repo',

+ 1 - 0
scripts/find-unsupported-borg-options

@@ -37,6 +37,7 @@ for sub_command in prune create check list info; do
             | grep -v '^--nobsdflags$' \
             | grep -v '^--nobsdflags$' \
             | grep -v '^--pattern$' \
             | grep -v '^--pattern$' \
             | grep -v '^--repository-only$' \
             | grep -v '^--repository-only$' \
+            | grep -v '^--show-rc$' \
             | grep -v '^--stats$' \
             | grep -v '^--stats$' \
             | grep -v '^--verbose$' \
             | grep -v '^--verbose$' \
             | grep -v '^--warning$' \
             | grep -v '^--warning$' \