config: Be less picky about comments after boolean values
authorGuido Günther <agx@sigxcpu.org>
Sun, 2 Feb 2020 17:38:48 +0000 (18:38 +0100)
committerGuido Günther <agx@sigxcpu.org>
Sun, 2 Feb 2020 17:39:31 +0000 (18:39 +0100)
This makes 'patch-numbers = False # comment' work.

Thanks: Mechtilde Stehmann for the report

gbp/config.py

index 495ec630ac6ed914b5ecfe23a13736d7fbc3fa9b..1ca8defd9e697d33e504cf8c7f3e29d60af5f127 100644 (file)
@@ -620,12 +620,17 @@ class GbpOptionParser(OptionParser):
         except KeyError:
             default = self.config[neg]
 
+        default = default.strip()
+        parts = default.split(" ", 2)
+        if len(parts) > 1 and parts[1] == '#':
+            default = parts[0]
+
         if default.lower() in ["true", "1"]:
             val = 'True'
         elif default.lower() in ["false", "0"]:
             val = 'False'
         else:
-            raise ValueError("Boolean options must be True or False")
+            raise ValueError("Boolean options must be True or False, not '%s'" % default)
         return eval(val)
 
     def get_default(self, option_name, **kwargs):