Calling interpolated variable "repository_label" instead of "label" for clarity (#874).
Some checks failed
build / docs (push) Blocked by required conditions
build / test (push) Has been cancelled

This commit is contained in:
Dan Helfman 2024-06-05 14:56:21 -07:00
parent 1ef2218919
commit f821d2c909
4 changed files with 16 additions and 6 deletions

4
NEWS
View File

@ -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.

View File

@ -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']]),

View File

@ -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`

View File

@ -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,