-
Notifications
You must be signed in to change notification settings - Fork 9
feat: add support of negation config rules #266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -20,7 +20,7 @@ | |||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| class ConfigRule: | ||||||||||||||||||||||||||||||||||||||
| def __init__(self, file_name: str, config_name: str = '') -> None: | ||||||||||||||||||||||||||||||||||||||
| def __init__(self, file_name: str, config_name: str = '', negated: bool = False) -> None: | ||||||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||||||
| ConfigRule represents the sdkconfig file and the config name. | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
|
|
@@ -30,20 +30,30 @@ def __init__(self, file_name: str, config_name: str = '') -> None: | |||||||||||||||||||||||||||||||||||||
| 'default' | ||||||||||||||||||||||||||||||||||||||
| - filename='sdkconfig.*', config_name=None - represents the set of configurations, names match the wildcard | ||||||||||||||||||||||||||||||||||||||
| value | ||||||||||||||||||||||||||||||||||||||
| - filename='sdkconfig.ci.test', negated=True - represents an exclusion rule, files matching this pattern | ||||||||||||||||||||||||||||||||||||||
| will be excluded from the build configurations | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| :param file_name: name of the sdkconfig file fragment, optionally with a single wildcard ('*' character). | ||||||||||||||||||||||||||||||||||||||
| can also be empty to indicate that the default configuration of the app should be used | ||||||||||||||||||||||||||||||||||||||
| :param config_name: name of the corresponding build configuration, or None if the value of wildcard is to be | ||||||||||||||||||||||||||||||||||||||
| used | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
31
to
39
|
||||||||||||||||||||||||||||||||||||||
| - filename='sdkconfig.*', config_name=None - represents the set of configurations, names match the wildcard | |
| value | |
| - filename='sdkconfig.ci.test', negated=True - represents an exclusion rule, files matching this pattern | |
| will be excluded from the build configurations | |
| :param file_name: name of the sdkconfig file fragment, optionally with a single wildcard ('*' character). | |
| can also be empty to indicate that the default configuration of the app should be used | |
| :param config_name: name of the corresponding build configuration, or None if the value of wildcard is to be | |
| used | |
| - filename='sdkconfig.*', config_name='' - represents the set of configurations, names match the wildcard | |
| value | |
| - filename='sdkconfig.ci.test', negated=True - represents an exclusion rule, files matching this pattern | |
| will be excluded from the build configurations | |
| :param file_name: name of the sdkconfig file fragment, optionally with a single wildcard ('*' character). | |
| can also be empty to indicate that the default configuration of the app should be used | |
| :param config_name: name of the corresponding build configuration, or an empty string if the value of the | |
| wildcard is to be used |
Copilot
AI
Apr 14, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
config_rules_from_str accepts a negation rule of just ! (or ! followed by whitespace), which produces ConfigRule(file_name=''). This later reaches Path(path).glob(rule.file_name) in finder.py and will raise at runtime for an empty glob pattern. Please validate negated_str is non-empty (and ideally .strip() it) and raise InvalidInput with a clear message when the pattern is empty; adding a small unit test for this case would prevent regressions.
| negated_str = rule_str[1:] | |
| if '=' in negated_str: | |
| raise InvalidInput(f'Negation rules must not have a config name: {rule_str}') | |
| negated_str = rule_str[1:].strip() | |
| if '=' in negated_str: | |
| raise InvalidInput(f'Negation rules must not have a config name: {rule_str}') | |
| if not negated_str: | |
| raise InvalidInput(f'Negation rules must include a non-empty pattern: {rule_str}') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Grammar fix: “The format is the as in the normal Config Rule.” should be “The format is the same as in the normal Config Rule.”