Pārlūkot izejas kodu

Fix the "create" action to omit the repository label prefix from Borg's output when databases are enabled (#996).

Dan Helfman 3 mēneši atpakaļ
vecāks
revīzija
aa4a9de3b2
4 mainītis faili ar 23 papildinājumiem un 8 dzēšanām
  1. 4 0
      NEWS
  2. 8 7
      borgmatic/execute.py
  3. 1 1
      pyproject.toml
  4. 10 0
      tests/unit/test_execute.py

+ 4 - 0
NEWS

@@ -1,3 +1,7 @@
+1.9.11.dev0
+ * #996: Fix the "create" action to omit the repository label prefix from Borg's output when
+   databases are enabled.
+
 1.9.10
  * #966: Add a "{credential ...}" syntax for loading systemd credentials into borgmatic
    configuration files. See the documentation for more information:

+ 8 - 7
borgmatic/execute.py

@@ -430,13 +430,14 @@ def execute_command_with_processes(
                 process.kill()
         raise
 
-    captured_outputs = log_outputs(
-        tuple(processes) + (command_process,),
-        (input_file, output_file),
-        output_log_level,
-        borg_local_path,
-        borg_exit_codes,
-    )
+    with borgmatic.logger.Log_prefix(None):  # Log command output without any prefix.
+        captured_outputs = log_outputs(
+            tuple(processes) + (command_process,),
+            (input_file, output_file),
+            output_log_level,
+            borg_local_path,
+            borg_exit_codes,
+        )
 
     if output_log_level is None:
         return captured_outputs.get(command_process)

+ 1 - 1
pyproject.toml

@@ -1,6 +1,6 @@
 [project]
 name = "borgmatic"
-version = "1.9.10"
+version = "1.9.11.dev0"
 authors = [
   { name="Dan Helfman", email="witten@torsion.org" },
 ]

+ 10 - 0
tests/unit/test_execute.py

@@ -554,6 +554,7 @@ def test_execute_command_with_processes_calls_full_command():
         cwd=None,
         close_fds=True,
     ).and_return(flexmock(stdout=None)).once()
+    flexmock(module.borgmatic.logger).should_receive('Log_prefix').and_return(flexmock())
     flexmock(module).should_receive('log_outputs')
 
     output = module.execute_command_with_processes(full_command, processes)
@@ -577,6 +578,7 @@ def test_execute_command_with_processes_returns_output_with_output_log_level_non
         cwd=None,
         close_fds=True,
     ).and_return(process).once()
+    flexmock(module.borgmatic.logger).should_receive('Log_prefix').and_return(flexmock())
     flexmock(module).should_receive('log_outputs').and_return({process: 'out'})
 
     output = module.execute_command_with_processes(full_command, processes, output_log_level=None)
@@ -600,6 +602,7 @@ def test_execute_command_with_processes_calls_full_command_with_output_file():
         cwd=None,
         close_fds=True,
     ).and_return(flexmock(stderr=None)).once()
+    flexmock(module.borgmatic.logger).should_receive('Log_prefix').and_return(flexmock())
     flexmock(module).should_receive('log_outputs')
 
     output = module.execute_command_with_processes(full_command, processes, output_file=output_file)
@@ -623,6 +626,7 @@ def test_execute_command_with_processes_calls_full_command_without_capturing_out
         close_fds=True,
     ).and_return(flexmock(wait=lambda: 0)).once()
     flexmock(module).should_receive('interpret_exit_code').and_return(module.Exit_status.SUCCESS)
+    flexmock(module.borgmatic.logger).should_receive('Log_prefix').and_return(flexmock())
     flexmock(module).should_receive('log_outputs')
 
     output = module.execute_command_with_processes(
@@ -648,6 +652,7 @@ def test_execute_command_with_processes_calls_full_command_with_input_file():
         cwd=None,
         close_fds=True,
     ).and_return(flexmock(stdout=None)).once()
+    flexmock(module.borgmatic.logger).should_receive('Log_prefix').and_return(flexmock())
     flexmock(module).should_receive('log_outputs')
 
     output = module.execute_command_with_processes(full_command, processes, input_file=input_file)
@@ -670,6 +675,7 @@ def test_execute_command_with_processes_calls_full_command_with_shell():
         cwd=None,
         close_fds=True,
     ).and_return(flexmock(stdout=None)).once()
+    flexmock(module.borgmatic.logger).should_receive('Log_prefix').and_return(flexmock())
     flexmock(module).should_receive('log_outputs')
 
     output = module.execute_command_with_processes(full_command, processes, shell=True)
@@ -692,6 +698,7 @@ def test_execute_command_with_processes_calls_full_command_with_extra_environmen
         cwd=None,
         close_fds=True,
     ).and_return(flexmock(stdout=None)).once()
+    flexmock(module.borgmatic.logger).should_receive('Log_prefix').and_return(flexmock())
     flexmock(module).should_receive('log_outputs')
 
     output = module.execute_command_with_processes(
@@ -716,6 +723,7 @@ def test_execute_command_with_processes_calls_full_command_with_working_director
         cwd='/working',
         close_fds=True,
     ).and_return(flexmock(stdout=None)).once()
+    flexmock(module.borgmatic.logger).should_receive('Log_prefix').and_return(flexmock())
     flexmock(module).should_receive('log_outputs')
 
     output = module.execute_command_with_processes(
@@ -740,6 +748,7 @@ def test_execute_command_with_processes_with_BORG_PASSPHRASE_FD_leaves_file_desc
         cwd=None,
         close_fds=False,
     ).and_return(flexmock(stdout=None)).once()
+    flexmock(module.borgmatic.logger).should_receive('Log_prefix').and_return(flexmock())
     flexmock(module).should_receive('log_outputs')
 
     output = module.execute_command_with_processes(
@@ -769,6 +778,7 @@ def test_execute_command_with_processes_kills_processes_on_error():
         cwd=None,
         close_fds=True,
     ).and_raise(subprocess.CalledProcessError(1, full_command, 'error')).once()
+    flexmock(module.borgmatic.logger).should_receive('Log_prefix').and_return(flexmock())
     flexmock(module).should_receive('log_outputs').never()
 
     with pytest.raises(subprocess.CalledProcessError):