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

Open
codimp wants to merge 5 commits from codimp/borgmatic:label-variable-interpolation-in-hook-context into main
Contributor

Goal

  • Add label interpolation variable in hook context for current repository at runtime, like repository
# Goal - Add `label` interpolation variable in hook context for current repository at runtime, like `repository`
codimp added 3 commits 2024-04-28 23:03:28 +00:00
witten requested changes 2024-04-29 01:42:17 +00:00
witten left a comment
Owner

This looks great.. Thank you for doing it! Only a few minor comments below. Also, what do you think of adding a test that if a repository label is present, then it ends up in the hook context? You could model it after one of the existing tests, such as the one you updated.

This looks great.. Thank you for doing it! Only a few minor comments below. Also, what do you think of adding a test that if a repository label is present, then it ends up in the hook context? You could model it after one of the existing tests, such as the one you updated.
@ -286,0 +286,4 @@
if 'label' in repository:
repository_label = repository['label']
else:
repository_label = ''
Owner

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.)
Author
Contributor

Good idea!

Good idea!
codimp marked this conversation as resolved
codimp added 1 commit 2024-04-29 08:38:28 +00:00
witten reviewed 2024-04-29 16:09:56 +00:00
@ -84,6 +84,8 @@ variables you can use here:
path of the borgmatic log file, only set when the `--log-file` flag is used
* `repository`: path of the current repository as configured in the current
borgmatic configuration file
* `label`: current repository label as configured in the current borgmatic
Owner

Sorry, another thing I think I mentioned on IRC.. What do you think of calling this repository_label instead of just label?

Sorry, another thing I think I mentioned on IRC.. What do you think of calling this `repository_label` instead of just `label`?
Author
Contributor

oups, right, my bad!

oups, right, my bad!
codimp marked this conversation as resolved
codimp added 1 commit 2024-04-29 19:17:00 +00:00
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
You can also view command line instructions.

Step 1:

From your project repository, check out a new branch and test the changes.
git checkout -b codimp-label-variable-interpolation-in-hook-context main
git pull label-variable-interpolation-in-hook-context

Step 2:

Merge the changes and update on Gitea.
git checkout main
git merge --no-ff codimp-label-variable-interpolation-in-hook-context
git push origin main
Sign in to join this conversation.
No reviewers
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: borgmatic-collective/borgmatic#861
No description provided.