Browse Source

Fix traceback when upgrading old INI-style configuration with upgrade-borgmatic-config (#367).

tags/1.5.11
Dan Helfman 1 week ago
parent
commit
9b819f32f8
4 changed files with 10 additions and 7 deletions
  1. +1
    -0
      NEWS
  2. +3
    -1
      borgmatic/commands/convert_config.py
  3. +2
    -2
      borgmatic/config/generate.py
  4. +4
    -4
      tests/integration/config/test_generate.py

+ 1
- 0
NEWS View File

@@ -4,6 +4,7 @@
* #355: Fix traceback when a database hook value is null in a configuration file.
* #361: Merge override values when specifying the "--override" flag multiple times. The previous
behavior was to take the value of the last "--override" flag only.
* #367: Fix traceback when upgrading old INI-style configuration with upgrade-borgmatic-config.
* #368: Fix signal forwarding from borgmatic to Borg resulting in recursion traceback.
* #369: Document support for Borg placeholders in repository names.



+ 3
- 1
borgmatic/commands/convert_config.py View File

@@ -99,7 +99,9 @@ def main(): # pragma: no cover
)

generate.write_configuration(
args.destination_config_filename, destination_config, mode=source_config_file_mode
args.destination_config_filename,
generate.render_configuration(destination_config),
mode=source_config_file_mode,
)

display_result(args)


+ 2
- 2
borgmatic/config/generate.py View File

@@ -99,7 +99,7 @@ def _comment_out_optional_configuration(rendered_config):
return '\n'.join(lines)


def _render_configuration(config):
def render_configuration(config):
'''
Given a config data structure of nested OrderedDicts, render the config as YAML and return it.
'''
@@ -284,5 +284,5 @@ def generate_sample_configuration(source_filename, destination_filename, schema_

write_configuration(
destination_filename,
_comment_out_optional_configuration(_render_configuration(destination_config)),
_comment_out_optional_configuration(render_configuration(destination_config)),
)

+ 4
- 4
tests/integration/config/test_generate.py View File

@@ -87,8 +87,8 @@ location:
assert module._comment_out_optional_configuration(config.strip()) == expected_config.strip()


def test_render_configuration_converts_configuration_to_yaml_string():
yaml_string = module._render_configuration({'foo': 'bar'})
def testrender_configuration_converts_configuration_to_yaml_string():
yaml_string = module.render_configuration({'foo': 'bar'})

assert yaml_string == 'foo: bar\n'

@@ -194,7 +194,7 @@ def test_generate_sample_configuration_does_not_raise():
flexmock(module.yaml).should_receive('round_trip_load')
flexmock(module).should_receive('_schema_to_sample_configuration')
flexmock(module).should_receive('merge_source_configuration_into_destination')
flexmock(module).should_receive('_render_configuration')
flexmock(module).should_receive('render_configuration')
flexmock(module).should_receive('_comment_out_optional_configuration')
flexmock(module).should_receive('write_configuration')

@@ -208,7 +208,7 @@ def test_generate_sample_configuration_with_source_filename_does_not_raise():
flexmock(module.load).should_receive('load_configuration')
flexmock(module).should_receive('_schema_to_sample_configuration')
flexmock(module).should_receive('merge_source_configuration_into_destination')
flexmock(module).should_receive('_render_configuration')
flexmock(module).should_receive('render_configuration')
flexmock(module).should_receive('_comment_out_optional_configuration')
flexmock(module).should_receive('write_configuration')



Loading…
Cancel
Save