Browse Source

Calling interpolated variable "repository_label" instead of "label" for clarity (#874).

Dan Helfman 1 year ago
parent
commit
f821d2c909

+ 2 - 2
NEWS

@@ -2,8 +2,8 @@
  * #860: Fix interaction between environment variable interpolation in constants and shell escaping.
  * #863: When color output is disabled (explicitly or implicitly), don't prefix each log line with
    the log level.
- * #874: Add configured repository "label" to the interpolated variables passed to before/after
-   command hooks.
+ * #874: Add the configured repository label as "repository_label" to the interpolated variables
+   passed to before/after command hooks.
 
 1.8.11
  * #815: Add optional Healthchecks auto-provisioning via "create_slug" option.

+ 1 - 1
borgmatic/commands/borgmatic.py

@@ -286,7 +286,7 @@ def run_actions(
     global_arguments = arguments['global']
     dry_run_label = ' (dry run; not making any changes)' if global_arguments.dry_run else ''
     hook_context = {
-        'label': repository.get('label', ''),
+        'repository_label': repository.get('label', ''),
         'log_file': global_arguments.log_file if global_arguments.log_file else '',
         # Deprecated: For backwards compatibility with borgmatic < 1.6.0.
         'repositories': ','.join([repo['path'] for repo in config['repositories']]),

+ 1 - 1
docs/how-to/add-preparation-and-cleanup-steps-to-backups.md

@@ -79,7 +79,7 @@ variables you can use here:
 
  * `configuration_filename`: borgmatic configuration filename in which the
    hook was defined
- * `label` <span class="minilink minilink-addedin">New in version
+ * `repository_label` <span class="minilink minilink-addedin">New in version
    1.8.12</span>: label of the current repository as configured in the current
    borgmatic configuration file
  * `log_file`

+ 12 - 2
tests/unit/commands/test_borgmatic.py

@@ -497,7 +497,12 @@ def test_run_actions_adds_label_file_to_hook_context():
         repository={'path': 'repo', 'label': 'my repo'},
         config={'repositories': []},
         config_paths=[],
-        hook_context={'label': 'my repo', 'log_file': '', 'repositories': '', 'repository': 'repo'},
+        hook_context={
+            'repository_label': 'my repo',
+            'log_file': '',
+            'repositories': '',
+            'repository': 'repo',
+        },
         local_borg_version=object,
         create_arguments=object,
         global_arguments=object,
@@ -531,7 +536,12 @@ def test_run_actions_adds_log_file_to_hook_context():
         repository={'path': 'repo'},
         config={'repositories': []},
         config_paths=[],
-        hook_context={'label': '', 'log_file': 'foo', 'repositories': '', 'repository': 'repo'},
+        hook_context={
+            'repository_label': '',
+            'log_file': 'foo',
+            'repositories': '',
+            'repository': 'repo',
+        },
         local_borg_version=object,
         create_arguments=object,
         global_arguments=object,