File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed
Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -25,14 +25,33 @@ def _target_keyboard_exists(target):
2525 return True
2626
2727
28+ def _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+
2843@cli .subcommand ('Validates the list of keyboard aliases.' , hidden = True )
2944def ci_validate_aliases (cli ):
3045 aliases = keyboard_alias_definitions ()
3146
3247 success = True
3348 for alias in aliases .keys ():
3449 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 ):
3655 cli .log .error (f'Keyboard alias { alias } has a target that doesn\' t exist: { target } ' )
3756 success = False
3857
You can’t perform that action at this time.
0 commit comments