From f821d2c9094bddde92a984c1826ff9b8cf24eda2 Mon Sep 17 00:00:00 2001 From: Dan Helfman Date: Wed, 5 Jun 2024 14:56:21 -0700 Subject: [PATCH] Calling interpolated variable "repository_label" instead of "label" for clarity (#874). --- NEWS | 4 ++-- borgmatic/commands/borgmatic.py | 2 +- ...add-preparation-and-cleanup-steps-to-backups.md | 2 +- tests/unit/commands/test_borgmatic.py | 14 ++++++++++++-- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/NEWS b/NEWS index 6b04454..9cc13fd 100644 --- a/NEWS +++ b/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. diff --git a/borgmatic/commands/borgmatic.py b/borgmatic/commands/borgmatic.py index bbaeb2c..354fbb5 100644 --- a/borgmatic/commands/borgmatic.py +++ b/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']]), diff --git a/docs/how-to/add-preparation-and-cleanup-steps-to-backups.md b/docs/how-to/add-preparation-and-cleanup-steps-to-backups.md index aec7319..b7487cb 100644 --- a/docs/how-to/add-preparation-and-cleanup-steps-to-backups.md +++ b/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` New in version + * `repository_label` New in version 1.8.12: label of the current repository as configured in the current borgmatic configuration file * `log_file` diff --git a/tests/unit/commands/test_borgmatic.py b/tests/unit/commands/test_borgmatic.py index f49f314..617da61 100644 --- a/tests/unit/commands/test_borgmatic.py +++ b/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,