mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-07-04 12:50:38 +08:00
Merge pull request #470 from Codium-ai/tr/glob
Enhance glob pattern handling and logging in file filtering
This commit is contained in:
9
Usage.md
9
Usage.md
@ -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:
|
||||||
|
@ -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 = []
|
||||||
|
@ -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
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user