Closes #1175 #1272
No reviewers
Labels
No labels
blocked
breaking
bug
data loss
design finalized
good first issue
new feature area
question / support
security
waiting for response
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
borgmatic-collective/borgmatic!1272
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "slantsh/borgmatic:flags"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I've added the two flags, "--files-changed=MODE" and "BORG_MSGPACK_VERSION_CHECK".
Also added a test for "--files-changed=MODE" flag in unit tests, seems to work on my end.
Thanks for taking his on!
@ -13,6 +13,7 @@ OPTION_TO_ENVIRONMENT_VARIABLE = {'borg_key_file': 'BORG_KEY_FILE','ssh_command': 'BORG_RSH','temporary_directory': 'TMPDIR','msgpack_version_check': 'BORG_MSGPACK_VERSION_CHECK',I think this should actually be in
DEFAULT_BOOL_OPTION_TO_ENVIRONMENT_VARIABLEinstead ofOPTION_TO_ENVIRONMENT_VARIABLE. That way, theTrue/Falsevalue (see comments below) will get transformed into the appropriate string representation (YES/NO) for passing to Borg.@ -167,2 +167,4 @@Defaults to true.example: falsefiles_changed:type: stringIf there are really only three valid values, you could make this an
enumstring. See elsewhere in this file for examples of that.Do not feel strongly.
@ -169,0 +171,4 @@description: |Threshold for considering a file as changed. Seehttps://borgbackup.readthedocs.io/en/stable/usage/create.html fordetails. Defaults to "mtime" (i.e., a file is consideredBased on those docs, it looks like the default is actually
ctime?@ -169,0 +173,4 @@https://borgbackup.readthedocs.io/en/stable/usage/create.html fordetails. Defaults to "mtime" (i.e., a file is consideredchanged if its mtime has changed since the last backup).example: mtime,sizeIf I'm reading the docs correctly,
mtimeis a valid value butmtime,sizeisn't.@ -563,2 +571,4 @@false and an interactive prompt from Borg.example: truemsgpack_version_check:type: stringIMO this should be a
booleanrather than astring. Seerelocated_repo_access_is_okfor an example of another environment variable option that works this way.@ -482,6 +482,7 @@ def test_make_base_create_command_with_store_config_false_omits_config_files():('flags', True, False, ()),('flags', False, True, ('--noflags',)),('flags', False, False, ('--nobsdflags',)),('files_changed', 'mtime', True, ('--files-changed', 'mtime')),Nice! Glad to see this was the only testing change required for this.
Oh, my bad, I've corrected the documentation and changed it to an enum string (According to the docs it should be just those 3 values? That is ctime, mtime or disabled.)
The new problem I've been facing is that
test_environment.pydoes fail and it seems that just addingBORG_MSGPACK_VERSION_CHECKis not enough.Can we set
BORG_MSGPACK_VERSION_CHECK's default value to be True?Right now I think every option in
DEFAULT_BOOL_OPTION_TO_ENVIRONMENT_VARIABLEis set to False by default if not specified, but I'm not sure..This part in
environment.py.Closes #1175to WIP: Closes #1175Yup!
You are correct that this is the first example of a default-
YESenvironment variable.So you might be able to add
if value is not None:to this code right before the environment variable gets set, just like in theforloop right below this one. What that would do is only set the environment variable if it's actually configured in borgmatic's config file. And if it's not, then Borg will have to use its own defaults. Which, as you've established, can vary by environment variable.This is what the proposed fix looks like right?
However, the test still fails as such
The only fix that I've tried is to just have an if statement to handle
msgpack_version_checkand set it to True like that.My take is that you can safely delete that test. What it's doing is ensuring that, if no configuration is provided for those particular options, then their corresponding environment variables still get set (with default values).
But with the change you've made with the addition of that
if value is not None:statement, borgmatic no longer sets the environment variables—unless there are actually configuration options for them. And so the test isn't needed any longer.Actually, instead of deleting the test outright, it might be nice to repurpose it to assert that only the following environment variables get set:
I believe that should pass even with the changes you have in place.
Oh, that makes sense! Thank you for being patient and guiding me, by the way.
I've made the changes and it does seem to pass all tests on my end.
Also want to ask whether I should use ruff to properly format it, because there are 2 other files that need formatting.
Of course! Thank you for your patience in getting through this PR process.
Great, glad to hear tests are passing now.
Yes! I imagine there are sometimes formatting differences across different versions of ruff, which would explain how it might introduce formatting changes to files you didn't edit. As long as things pass in CI, you're all good.
This looks fine to merge to me! When you're ready, please feel free to remove the WIP prefix.
WIP: Closes #1175to Closes #1175All set, I've removed the WIP prefix.