summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/python/qmk/cli/ci/validate_aliases.py21
1 files changed, 20 insertions, 1 deletions
diff --git a/lib/python/qmk/cli/ci/validate_aliases.py b/lib/python/qmk/cli/ci/validate_aliases.py
index 8b062dbe56..4f2fe6c941 100644
--- a/lib/python/qmk/cli/ci/validate_aliases.py
+++ b/lib/python/qmk/cli/ci/validate_aliases.py
@@ -25,6 +25,21 @@ def _target_keyboard_exists(target):
25 return True 25 return True
26 26
27 27
28def _alias_not_self(alias):
29 """Check if alias points to itself, either directly or within a circular reference
30 """
31 aliases = keyboard_alias_definitions()
32
33 found = set()
34 while alias in aliases:
35 found.add(alias)
36 alias = aliases[alias].get('target', alias)
37 if alias in found:
38 return False
39
40 return True
41
42
28@cli.subcommand('Validates the list of keyboard aliases.', hidden=True) 43@cli.subcommand('Validates the list of keyboard aliases.', hidden=True)
29def ci_validate_aliases(cli): 44def ci_validate_aliases(cli):
30 aliases = keyboard_alias_definitions() 45 aliases = keyboard_alias_definitions()
@@ -32,7 +47,11 @@ def ci_validate_aliases(cli):
32 success = True 47 success = True
33 for alias in aliases.keys(): 48 for alias in aliases.keys():
34 target = aliases[alias].get('target', None) 49 target = aliases[alias].get('target', None)
35 if not _target_keyboard_exists(target): 50 if not _alias_not_self(alias):
51 cli.log.error(f'Keyboard alias {alias} should not point to itself')
52 success = False
53
54 elif not _target_keyboard_exists(target):
36 cli.log.error(f'Keyboard alias {alias} has a target that doesn\'t exist: {target}') 55 cli.log.error(f'Keyboard alias {alias} has a target that doesn\'t exist: {target}')
37 success = False 56 success = False
38 57