Преглед изворни кода

List the configured "when" action names in the log entries for command hooks (#1063).

Dan Helfman пре 1 месец
родитељ
комит
7de1c2121c
3 измењених фајлова са 6 додато и 4 уклоњено
  1. 1 0
      NEWS
  2. 5 2
      borgmatic/hooks/command.py
  3. 0 2
      tests/end-to-end/test_environment_variable.py

+ 1 - 0
NEWS

@@ -8,6 +8,7 @@
    executed (implicitly or explicitly).
  * #1060: Don't run action command hooks for actions listed in the "skip_actions" option.
  * #1062: Fix a regression that broke environment variable interpolation.
+ * #1063: List the configured "when" action names in the log entries for command hooks.
 
 2.0.1
  * #1057: Fix argument parsing to avoid using Python 3.12+ string features. Now borgmatic will

+ 5 - 2
borgmatic/hooks/command.py

@@ -82,11 +82,14 @@ def execute_hooks(command_hooks, umask, working_directory, dry_run, **context):
 
     for hook_config in command_hooks:
         commands = hook_config.get('run')
+        when_description = (
+            f"{'/'.join(hook_config.get('when'))} " if hook_config.get('when') else ''
+        )
 
         if 'before' in hook_config:
-            description = f'before {hook_config.get("before")}'
+            description = f'before {when_description}{hook_config.get("before")}'
         elif 'after' in hook_config:
-            description = f'after {hook_config.get("after")}'
+            description = f'after {when_description}{hook_config.get("after")}'
         else:
             raise ValueError(f'Invalid hook configuration: {hook_config}')
 

+ 0 - 2
tests/end-to-end/test_environment_variable.py

@@ -5,8 +5,6 @@ import subprocess
 import sys
 import tempfile
 
-import pytest
-
 
 def generate_configuration(config_path, repository_path):
     '''