Merge pull request #470 from Codium-ai/tr/glob

Enhance glob pattern handling and logging in file filtering
This commit is contained in:
mrT23
2023-11-22 23:19:09 -08:00
committed by GitHub
3 changed files with 14 additions and 4 deletions

View File

@ -37,9 +37,14 @@ To ignore files or directories, edit the **[ignore.toml](/pr_agent/settings/igno
- `IGNORE.GLOB` - `IGNORE.GLOB`
- `IGNORE.REGEX` - `IGNORE.REGEX`
For example, to ignore python files in a PR, set: For example, to ignore python files in a PR with online usage, comment on a PR:
`/review --ignore.glob=['*.py']`
`ignore.glob = ['*.py']` To ignore python files in all PRs, set in a configuration file:
```
[ignore]
glob = ['*.py']
```
#### git provider #### git provider
The [git_provider](pr_agent/settings/configuration.toml#L4) field in the configuration file determines the GIT provider that will be used by PR-Agent. Currently, the following providers are supported: The [git_provider](pr_agent/settings/configuration.toml#L4) field in the configuration file determines the GIT provider that will be used by PR-Agent. Currently, the following providers are supported:

View File

@ -11,7 +11,12 @@ def filter_ignored(files):
try: try:
# load regex patterns, and translate glob patterns to regex # load regex patterns, and translate glob patterns to regex
patterns = get_settings().ignore.regex patterns = get_settings().ignore.regex
patterns += [fnmatch.translate(glob) for glob in get_settings().ignore.glob] if isinstance(patterns, str):
patterns = [patterns]
glob_setting = get_settings().ignore.glob
if isinstance(glob_setting, str): # --ignore.glob=[.*utils.py], --ignore.glob=.*utils.py
glob_setting = glob_setting.strip('[]').split(",")
patterns += [fnmatch.translate(glob) for glob in glob_setting]
# compile all valid patterns # compile all valid patterns
compiled_patterns = [] compiled_patterns = []

View File

@ -282,7 +282,7 @@ def _fix_key_value(key: str, value: str):
try: try:
value = yaml.safe_load(value) value = yaml.safe_load(value)
except Exception as e: except Exception as e:
get_logger().error(f"Failed to parse YAML for config override {key}={value}", exc_info=e) get_logger().debug(f"Failed to parse YAML for config override {key}={value}", exc_info=e)
return key, value return key, value