Fix an error when running "borg key export" through borgmatic (#719).
This commit is contained in:
parent
c3004c6090
commit
b242078f54
4 changed files with 24 additions and 4 deletions
3
NEWS
3
NEWS
|
@ -1,3 +1,6 @@
|
||||||
|
1.7.16.dev0
|
||||||
|
* #719: Fix an error when running "borg key export" through borgmatic.
|
||||||
|
|
||||||
1.7.15
|
1.7.15
|
||||||
* #326: Add configuration options and command-line flags for backing up a database from one
|
* #326: Add configuration options and command-line flags for backing up a database from one
|
||||||
location while restoring it somewhere else.
|
location while restoring it somewhere else.
|
||||||
|
|
|
@ -216,15 +216,21 @@ def parse_arguments_for_actions(unparsed_arguments, action_parsers, global_parse
|
||||||
arguments['global'], remaining = global_parser.parse_known_args(unparsed_arguments)
|
arguments['global'], remaining = global_parser.parse_known_args(unparsed_arguments)
|
||||||
remaining_action_arguments.append(remaining)
|
remaining_action_arguments.append(remaining)
|
||||||
|
|
||||||
# Prevent action names that follow "--config" paths from being considered as additional paths.
|
# Prevent action names and arguments that follow "--config" paths from being considered as
|
||||||
|
# additional paths.
|
||||||
for argument_name in arguments.keys():
|
for argument_name in arguments.keys():
|
||||||
if argument_name == 'global':
|
if argument_name == 'global':
|
||||||
continue
|
continue
|
||||||
|
|
||||||
for action_name in [argument_name] + ACTION_ALIASES.get(argument_name, []):
|
for action_name in [argument_name] + ACTION_ALIASES.get(argument_name, []):
|
||||||
if action_name in arguments['global'].config_paths:
|
try:
|
||||||
arguments['global'].config_paths.remove(action_name)
|
action_name_index = arguments['global'].config_paths.index(action_name)
|
||||||
|
arguments['global'].config_paths = arguments['global'].config_paths[
|
||||||
|
:action_name_index
|
||||||
|
]
|
||||||
break
|
break
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
|
|
||||||
return (
|
return (
|
||||||
arguments,
|
arguments,
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -1,6 +1,6 @@
|
||||||
from setuptools import find_packages, setup
|
from setuptools import find_packages, setup
|
||||||
|
|
||||||
VERSION = '1.7.15'
|
VERSION = '1.7.16.dev0'
|
||||||
|
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
|
|
|
@ -52,6 +52,17 @@ def test_parse_arguments_with_action_after_config_path_omits_aliased_action():
|
||||||
assert arguments['rcreate'].encryption_mode == 'repokey'
|
assert arguments['rcreate'].encryption_mode == 'repokey'
|
||||||
|
|
||||||
|
|
||||||
|
def test_parse_arguments_with_action_and_positional_arguments_after_config_path_omits_action_and_arguments():
|
||||||
|
flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
|
||||||
|
|
||||||
|
arguments = module.parse_arguments('--config', 'myconfig', 'borg', 'key', 'export')
|
||||||
|
|
||||||
|
global_arguments = arguments['global']
|
||||||
|
assert global_arguments.config_paths == ['myconfig']
|
||||||
|
assert 'borg' in arguments
|
||||||
|
assert arguments['borg'].options == ['key', 'export']
|
||||||
|
|
||||||
|
|
||||||
def test_parse_arguments_with_verbosity_overrides_default():
|
def test_parse_arguments_with_verbosity_overrides_default():
|
||||||
config_paths = ['default']
|
config_paths = ['default']
|
||||||
flexmock(module.collect).should_receive('get_default_config_paths').and_return(config_paths)
|
flexmock(module.collect).should_receive('get_default_config_paths').and_return(config_paths)
|
||||||
|
|
Loading…
Reference in a new issue