Use --glob-archives instead of --prefix on rlist command (#557).
This commit is contained in:
parent
28d847b8b1
commit
596dd49cf5
3 changed files with 37 additions and 15 deletions
|
@ -41,7 +41,7 @@ def make_list_command(
|
|||
)
|
||||
+ flags.make_flags('remote-path', remote_path)
|
||||
+ flags.make_flags('lock-wait', lock_wait)
|
||||
+ flags.make_flags_from_arguments(list_arguments, excludes=MAKE_FLAGS_EXCLUDES,)
|
||||
+ flags.make_flags_from_arguments(list_arguments, excludes=MAKE_FLAGS_EXCLUDES)
|
||||
+ (
|
||||
flags.make_repository_archive_flags(
|
||||
repository, list_arguments.archive, local_borg_version
|
||||
|
|
|
@ -51,7 +51,7 @@ def resolve_archive_name(
|
|||
return latest_archive
|
||||
|
||||
|
||||
MAKE_FLAGS_EXCLUDES = ('repository',)
|
||||
MAKE_FLAGS_EXCLUDES = ('repository', 'prefix')
|
||||
|
||||
|
||||
def make_rlist_command(
|
||||
|
@ -86,7 +86,12 @@ def make_rlist_command(
|
|||
)
|
||||
+ flags.make_flags('remote-path', remote_path)
|
||||
+ flags.make_flags('lock-wait', lock_wait)
|
||||
+ flags.make_flags_from_arguments(rlist_arguments, excludes=MAKE_FLAGS_EXCLUDES,)
|
||||
+ (
|
||||
flags.make_flags('glob-archives', f'{rlist_arguments.prefix}*')
|
||||
if rlist_arguments.prefix
|
||||
else ()
|
||||
)
|
||||
+ flags.make_flags_from_arguments(rlist_arguments, excludes=MAKE_FLAGS_EXCLUDES)
|
||||
+ flags.make_repository_flags(repository, local_borg_version)
|
||||
)
|
||||
|
||||
|
|
|
@ -153,7 +153,7 @@ def test_make_rlist_command_includes_log_info():
|
|||
repository='repo',
|
||||
storage_config={},
|
||||
local_borg_version='1.2.3',
|
||||
rlist_arguments=flexmock(archive=None, paths=None, json=False),
|
||||
rlist_arguments=flexmock(archive=None, paths=None, json=False, prefix=None),
|
||||
)
|
||||
|
||||
assert command == ('borg', 'list', '--info', 'repo')
|
||||
|
@ -169,7 +169,7 @@ def test_make_rlist_command_includes_json_but_not_info():
|
|||
repository='repo',
|
||||
storage_config={},
|
||||
local_borg_version='1.2.3',
|
||||
rlist_arguments=flexmock(archive=None, paths=None, json=True),
|
||||
rlist_arguments=flexmock(archive=None, paths=None, json=True, prefix=None),
|
||||
)
|
||||
|
||||
assert command == ('borg', 'list', '--json', 'repo')
|
||||
|
@ -185,7 +185,7 @@ def test_make_rlist_command_includes_log_debug():
|
|||
repository='repo',
|
||||
storage_config={},
|
||||
local_borg_version='1.2.3',
|
||||
rlist_arguments=flexmock(archive=None, paths=None, json=False),
|
||||
rlist_arguments=flexmock(archive=None, paths=None, json=False, prefix=None),
|
||||
)
|
||||
|
||||
assert command == ('borg', 'list', '--debug', '--show-rc', 'repo')
|
||||
|
@ -201,7 +201,7 @@ def test_make_rlist_command_includes_json_but_not_debug():
|
|||
repository='repo',
|
||||
storage_config={},
|
||||
local_borg_version='1.2.3',
|
||||
rlist_arguments=flexmock(archive=None, paths=None, json=True),
|
||||
rlist_arguments=flexmock(archive=None, paths=None, json=True, prefix=None),
|
||||
)
|
||||
|
||||
assert command == ('borg', 'list', '--json', 'repo')
|
||||
|
@ -216,7 +216,7 @@ def test_make_rlist_command_includes_json():
|
|||
repository='repo',
|
||||
storage_config={},
|
||||
local_borg_version='1.2.3',
|
||||
rlist_arguments=flexmock(archive=None, paths=None, json=True),
|
||||
rlist_arguments=flexmock(archive=None, paths=None, json=True, prefix=None),
|
||||
)
|
||||
|
||||
assert command == ('borg', 'list', '--json', 'repo')
|
||||
|
@ -225,7 +225,7 @@ def test_make_rlist_command_includes_json():
|
|||
def test_make_rlist_command_includes_lock_wait():
|
||||
flexmock(module.flags).should_receive('make_flags').and_return(()).and_return(
|
||||
('--lock-wait', '5')
|
||||
)
|
||||
).and_return(())
|
||||
flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(())
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
|
||||
|
@ -233,7 +233,7 @@ def test_make_rlist_command_includes_lock_wait():
|
|||
repository='repo',
|
||||
storage_config={'lock_wait': 5},
|
||||
local_borg_version='1.2.3',
|
||||
rlist_arguments=flexmock(archive=None, paths=None, json=False),
|
||||
rlist_arguments=flexmock(archive=None, paths=None, json=False, prefix=None),
|
||||
)
|
||||
|
||||
assert command == ('borg', 'list', '--lock-wait', '5', 'repo')
|
||||
|
@ -248,7 +248,7 @@ def test_make_rlist_command_includes_local_path():
|
|||
repository='repo',
|
||||
storage_config={},
|
||||
local_borg_version='1.2.3',
|
||||
rlist_arguments=flexmock(archive=None, paths=None, json=False),
|
||||
rlist_arguments=flexmock(archive=None, paths=None, json=False, prefix=None),
|
||||
local_path='borg2',
|
||||
)
|
||||
|
||||
|
@ -258,7 +258,7 @@ def test_make_rlist_command_includes_local_path():
|
|||
def test_make_rlist_command_includes_remote_path():
|
||||
flexmock(module.flags).should_receive('make_flags').and_return(
|
||||
('--remote-path', 'borg2')
|
||||
).and_return(())
|
||||
).and_return(()).and_return(())
|
||||
flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(())
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
|
||||
|
@ -266,13 +266,30 @@ def test_make_rlist_command_includes_remote_path():
|
|||
repository='repo',
|
||||
storage_config={},
|
||||
local_borg_version='1.2.3',
|
||||
rlist_arguments=flexmock(archive=None, paths=None, json=False),
|
||||
rlist_arguments=flexmock(archive=None, paths=None, json=False, prefix=None),
|
||||
remote_path='borg2',
|
||||
)
|
||||
|
||||
assert command == ('borg', 'list', '--remote-path', 'borg2', 'repo')
|
||||
|
||||
|
||||
def test_make_rlist_command_transforms_prefix_into_glob_archives():
|
||||
flexmock(module.flags).should_receive('make_flags').and_return(()).and_return(()).and_return(
|
||||
('--glob-archives', 'foo*')
|
||||
)
|
||||
flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(())
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
|
||||
command = module.make_rlist_command(
|
||||
repository='repo',
|
||||
storage_config={},
|
||||
local_borg_version='1.2.3',
|
||||
rlist_arguments=flexmock(archive=None, paths=None, json=False, prefix='foo'),
|
||||
)
|
||||
|
||||
assert command == ('borg', 'list', '--glob-archives', 'foo*', 'repo')
|
||||
|
||||
|
||||
def test_make_rlist_command_includes_short():
|
||||
flexmock(module.flags).should_receive('make_flags').and_return(())
|
||||
flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(('--short',))
|
||||
|
@ -282,7 +299,7 @@ def test_make_rlist_command_includes_short():
|
|||
repository='repo',
|
||||
storage_config={},
|
||||
local_borg_version='1.2.3',
|
||||
rlist_arguments=flexmock(archive=None, paths=None, json=False, short=True),
|
||||
rlist_arguments=flexmock(archive=None, paths=None, json=False, prefix=None, short=True),
|
||||
)
|
||||
|
||||
assert command == ('borg', 'list', '--short', 'repo')
|
||||
|
@ -291,7 +308,6 @@ def test_make_rlist_command_includes_short():
|
|||
@pytest.mark.parametrize(
|
||||
'argument_name',
|
||||
(
|
||||
'prefix',
|
||||
'glob_archives',
|
||||
'sort_by',
|
||||
'first',
|
||||
|
@ -317,6 +333,7 @@ def test_make_rlist_command_includes_additional_flags(argument_name):
|
|||
archive=None,
|
||||
paths=None,
|
||||
json=False,
|
||||
prefix=None,
|
||||
find_paths=None,
|
||||
format=None,
|
||||
**{argument_name: 'value'},
|
||||
|
|
Loading…
Reference in a new issue