[Feature] Add label variable interpolation in hook context #861

Closed
codimp wants to merge 5 commits from codimp/borgmatic:label-variable-interpolation-in-hook-context into main
Showing only changes of commit b36e11d3ca - Show all commits

View File

@ -283,9 +283,14 @@ def run_actions(
'''
add_custom_log_levels()
repository_path = os.path.expanduser(repository['path'])
if 'label' in repository:
repository_label = repository['label']
else:
repository_label = ''
codimp marked this conversation as resolved Outdated

You could simplify this all to just: repository_label = repository.get('label', '')

It could even be inline below without the temporary variable. (Do not feel strongly.)

You could simplify this all to just: `repository_label = repository.get('label', '')` It could even be inline below without the temporary variable. (Do not feel strongly.)

Good idea!

Good idea!
global_arguments = arguments['global']
dry_run_label = ' (dry run; not making any changes)' if global_arguments.dry_run else ''
hook_context = {
'label': repository_label,
'repository': repository_path,
# Deprecated: For backwards compatibility with borgmatic < 1.6.0.
'repositories': ','.join([repo['path'] for repo in config['repositories']]),