From be0186cb7a9c64aea47c25346203465cb5fcc967 Mon Sep 17 00:00:00 2001 From: Erovia Date: Sat, 3 Oct 2020 14:18:49 +0100 Subject: [PATCH] Fix a bug in the CLI's rules.mk parsing code DEFAULT_FOLDER could cause unexpected behaviour when the user specified the full revision of the board. --- lib/python/qmk/keyboard.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/python/qmk/keyboard.py b/lib/python/qmk/keyboard.py index d1f2a301df58..41543b86c129 100644 --- a/lib/python/qmk/keyboard.py +++ b/lib/python/qmk/keyboard.py @@ -38,7 +38,7 @@ def rules_mk(keyboard): Returns: a dictionary representing the content of the entire rules.mk tree for a keyboard """ - keyboard = Path(keyboard) + keyboard = orig_kb = Path(keyboard) cur_dir = Path('keyboards') rules = parse_rules_mk_file(cur_dir / keyboard / 'rules.mk') @@ -49,6 +49,11 @@ def rules_mk(keyboard): cur_dir = cur_dir / dir rules = parse_rules_mk_file(cur_dir / 'rules.mk', rules) + # Removing DEFAULT_FOLDER if the full revision was specified as it can cause unexpected + # behaviour otherwise. + if 'DEFAULT_FOLDER' in rules and orig_kb not in Path(rules['DEFAULT_FOLDER']).parents: + rules.pop('DEFAULT_FOLDER') + return rules