mirror of
https://github.com/qmk/qmk_firmware.git
synced 2025-07-17 21:22:05 +00:00
Also check for circular refs
This commit is contained in:
parent
3a025f41e0
commit
60f2f215c2
@ -25,6 +25,21 @@ def _target_keyboard_exists(target):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def _alias_not_self(alias):
|
||||||
|
"""Check if alias points to itself, either directly or within a circular reference
|
||||||
|
"""
|
||||||
|
aliases = keyboard_alias_definitions()
|
||||||
|
|
||||||
|
found = set()
|
||||||
|
while alias in aliases:
|
||||||
|
found.add(alias)
|
||||||
|
alias = aliases[alias].get('target', alias)
|
||||||
|
if alias in found:
|
||||||
|
return False
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
@cli.subcommand('Validates the list of keyboard aliases.', hidden=True)
|
@cli.subcommand('Validates the list of keyboard aliases.', hidden=True)
|
||||||
def ci_validate_aliases(cli):
|
def ci_validate_aliases(cli):
|
||||||
aliases = keyboard_alias_definitions()
|
aliases = keyboard_alias_definitions()
|
||||||
@ -32,11 +47,11 @@ def ci_validate_aliases(cli):
|
|||||||
success = True
|
success = True
|
||||||
for alias in aliases.keys():
|
for alias in aliases.keys():
|
||||||
target = aliases[alias].get('target', None)
|
target = aliases[alias].get('target', None)
|
||||||
if alias == target:
|
if not _alias_not_self(alias):
|
||||||
cli.log.error(f'Keyboard alias {alias} should not point to itself')
|
cli.log.error(f'Keyboard alias {alias} should not point to itself')
|
||||||
success = False
|
success = False
|
||||||
|
|
||||||
if not _target_keyboard_exists(target):
|
elif not _target_keyboard_exists(target):
|
||||||
cli.log.error(f'Keyboard alias {alias} has a target that doesn\'t exist: {target}')
|
cli.log.error(f'Keyboard alias {alias} has a target that doesn\'t exist: {target}')
|
||||||
success = False
|
success = False
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user