浏览代码

Fix generated configuration to also include a "keep_daily" value so pruning works out of the box.

Dan Helfman 6 年之前
父节点
当前提交
746428ed44
共有 3 个文件被更改,包括 17 次插入4 次删除
  1. 4 0
      NEWS
  2. 12 3
      borgmatic/config/generate.py
  3. 1 1
      setup.py

+ 4 - 0
NEWS

@@ -1,3 +1,7 @@
+1.2.6
+ * Fix generated configuration to also include a "keep_daily" value so pruning works out of the
+   box.
+
 1.2.5
  * #57: When generating sample configuration with generate-borgmatic-config, comment out all
    optional configuration so as to streamline the initial configuration process.

+ 12 - 3
borgmatic/config/generate.py

@@ -55,6 +55,10 @@ def _comment_out_line(line):
     return '#'.join((one_indent, line[INDENT:]))
 
 
+REQUIRED_KEYS = {'source_directories', 'repositories', 'keep_daily'}
+REQUIRED_SECTION_NAMES = {'location', 'retention'}
+
+
 def _comment_out_optional_configuration(rendered_config):
     '''
     Post-process a rendered configuration string to comment out optional key/values. The idea is
@@ -68,12 +72,17 @@ def _comment_out_optional_configuration(rendered_config):
     required = False
 
     for line in rendered_config.split('\n'):
+        key = line.strip().split(':')[0]
+
+        if key in REQUIRED_SECTION_NAMES:
+            lines.append(line)
+            continue
+
         # Upon encountering a required configuration option, skip commenting out lines until the
         # next blank line.
-        stripped_line = line.strip()
-        if stripped_line in {'source_directories:', 'repositories:'} or line == 'location:':
+        if key in REQUIRED_KEYS:
             required = True
-        elif not stripped_line:
+        elif not key:
             required = False
 
         lines.append(_comment_out_line(line) if not required else line)

+ 1 - 1
setup.py

@@ -1,7 +1,7 @@
 from setuptools import setup, find_packages
 
 
-VERSION = '1.2.5'
+VERSION = '1.2.6'
 
 
 setup(