From 4d7a2876a517d2005bec005fdd7d01796c5905f2 Mon Sep 17 00:00:00 2001 From: Dan Helfman Date: Sat, 22 Jul 2023 10:26:52 -0700 Subject: [PATCH] Fix for "prune" action error when using the "keep_exclude_tags" option in configuration (#728). --- NEWS | 3 +++ borgmatic/borg/prune.py | 2 +- setup.py | 2 +- tests/unit/borg/test_prune.py | 13 +++++++++++++ 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 73f456e0..94f69933 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,6 @@ +1.8.1.dev0 + * #728: Fix for "prune" action error when using the "keep_exclude_tags" option in configuration. + 1.8.0 * #575: BREAKING: For the "borgmatic borg" action, instead of implicitly injecting repository/archive into the resulting Borg command-line, pass repository to Borg via an diff --git a/borgmatic/borg/prune.py b/borgmatic/borg/prune.py index 46c7f34b..79a43da3 100644 --- a/borgmatic/borg/prune.py +++ b/borgmatic/borg/prune.py @@ -26,7 +26,7 @@ def make_prune_flags(config, local_borg_version): flag_pairs = ( ('--' + option_name.replace('_', '-'), str(value)) for option_name, value in config.items() - if option_name.startswith('keep_') + if option_name.startswith('keep_') and option_name != 'keep_exclude_tags' ) prefix = config.get('prefix') diff --git a/setup.py b/setup.py index 6e5e4190..717acb12 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ from setuptools import find_packages, setup -VERSION = '1.8.0' +VERSION = '1.8.1.dev0' setup( diff --git a/tests/unit/borg/test_prune.py b/tests/unit/borg/test_prune.py index 971eb1e6..34a1563a 100644 --- a/tests/unit/borg/test_prune.py +++ b/tests/unit/borg/test_prune.py @@ -118,6 +118,19 @@ def test_make_prune_flags_without_prefix_uses_archive_name_format_instead(): assert result == expected +def test_make_prune_flags_ignores_keep_exclude_tags_in_config(): + config = { + 'keep_daily': 1, + 'keep_exclude_tags': True, + } + flexmock(module.feature).should_receive('available').and_return(True) + flexmock(module.flags).should_receive('make_match_archives_flags').and_return(()) + + result = module.make_prune_flags(config, local_borg_version='1.2.3') + + assert result == ('--keep-daily', '1') + + PRUNE_COMMAND = ('borg', 'prune', '--keep-daily', '1', '--keep-weekly', '2', '--keep-monthly', '3')