annotations: update: update note when config is changing
authorAndrea Righi <andrea.righi@canonical.com>
Fri, 20 Oct 2023 07:42:57 +0000 (09:42 +0200)
committerAndrea Righi <andrea.righi@canonical.com>
Mon, 11 Dec 2023 10:00:49 +0000 (11:00 +0100)
When a new .config is imported some values may change, but the
corresponding note is not always updated to reflect the new value.

This is wrong and it can lead to errors and incorrect information in the
annotations file.

To prevent this from happening automatically add a TODO note when any
config with a note is changing to force the reviewer to update the note.

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
kconfig/annotations.py

index 7a23d2b392b11b4c50c05e33784621bc00bc5767..145523ce03633931dffa8e9fee82cb204aef8c07 100644 (file)
@@ -238,6 +238,14 @@ class Annotation(Config):
                 val = "-"
             if conf in self.config:
                 if "policy" in self.config[conf]:
+                    # Add a TODO if a config with a note is changing and print
+                    # a warning
+                    old_val = self.search_config(config=conf, arch=arch, flavour=flavour)
+                    if old_val:
+                        old_val = old_val[conf]
+                    if val != old_val and "note" in self.config[conf]:
+                        self.config[conf]['note'] = "TODO: update note"
+                        print(f"WARNING: {conf} changed from {old_val} to {val}, updating note")
                     self.config[conf]["policy"][flavour] = val
                 else:
                     self.config[conf]["policy"] = {flavour: val}