Fix a traceback when the "repositories" option contains both strings and key/value pairs (#794).
This commit is contained in:
parent
c34ad7dde7
commit
8b49a59aff
4 changed files with 14 additions and 15 deletions
3
NEWS
3
NEWS
|
@ -1,3 +1,6 @@
|
||||||
|
1.8.6.dev0
|
||||||
|
* #794: Fix a traceback when the "repositories" option contains both strings and key/value pairs.
|
||||||
|
|
||||||
1.8.5
|
1.8.5
|
||||||
* #701: Add a "skip_actions" option to skip running particular actions, handy for append-only or
|
* #701: Add a "skip_actions" option to skip running particular actions, handy for append-only or
|
||||||
checkless configurations. See the documentation for more information:
|
checkless configurations. See the documentation for more information:
|
||||||
|
|
|
@ -192,7 +192,7 @@ def normalize(config_filename, config):
|
||||||
# Upgrade remote repositories to ssh:// syntax, required in Borg 2.
|
# Upgrade remote repositories to ssh:// syntax, required in Borg 2.
|
||||||
repositories = config.get('repositories')
|
repositories = config.get('repositories')
|
||||||
if repositories:
|
if repositories:
|
||||||
if isinstance(repositories[0], str):
|
if any(isinstance(repository, str) for repository in repositories):
|
||||||
logs.append(
|
logs.append(
|
||||||
logging.makeLogRecord(
|
logging.makeLogRecord(
|
||||||
dict(
|
dict(
|
||||||
|
@ -202,7 +202,10 @@ def normalize(config_filename, config):
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
config['repositories'] = [{'path': repository} for repository in repositories]
|
config['repositories'] = [
|
||||||
|
{'path': repository} if isinstance(repository, str) else repository
|
||||||
|
for repository in repositories
|
||||||
|
]
|
||||||
repositories = config['repositories']
|
repositories = config['repositories']
|
||||||
|
|
||||||
config['repositories'] = []
|
config['repositories'] = []
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -1,6 +1,6 @@
|
||||||
from setuptools import find_packages, setup
|
from setuptools import find_packages, setup
|
||||||
|
|
||||||
VERSION = '1.8.5'
|
VERSION = '1.8.6.dev0'
|
||||||
|
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
|
|
|
@ -216,6 +216,11 @@ def test_normalize_sections_with_only_scalar_raises():
|
||||||
{'repositories': [{'path': '/repo'}]},
|
{'repositories': [{'path': '/repo'}]},
|
||||||
True,
|
True,
|
||||||
),
|
),
|
||||||
|
(
|
||||||
|
{'repositories': [{'path': 'first'}, 'file:///repo']},
|
||||||
|
{'repositories': [{'path': 'first'}, {'path': '/repo'}]},
|
||||||
|
True,
|
||||||
|
),
|
||||||
(
|
(
|
||||||
{'repositories': [{'path': 'foo@bar:/repo', 'label': 'foo'}]},
|
{'repositories': [{'path': 'foo@bar:/repo', 'label': 'foo'}]},
|
||||||
{'repositories': [{'path': 'ssh://foo@bar/repo', 'label': 'foo'}]},
|
{'repositories': [{'path': 'ssh://foo@bar/repo', 'label': 'foo'}]},
|
||||||
|
@ -251,15 +256,3 @@ def test_normalize_applies_hard_coded_normalization_to_config(
|
||||||
assert logs
|
assert logs
|
||||||
else:
|
else:
|
||||||
assert logs == []
|
assert logs == []
|
||||||
|
|
||||||
|
|
||||||
def test_normalize_raises_error_if_repository_data_is_not_consistent():
|
|
||||||
flexmock(module).should_receive('normalize_sections').and_return([])
|
|
||||||
|
|
||||||
with pytest.raises(TypeError):
|
|
||||||
module.normalize(
|
|
||||||
'test.yaml',
|
|
||||||
{
|
|
||||||
'repositories': [{'path': 'foo@bar:/repo', 'label': 'foo'}, 'file:///repo'],
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
Loading…
Reference in a new issue