From e80a0ed9c84620afb51b6ddda25e8eb8cd3a8032 Mon Sep 17 00:00:00 2001 From: mrT23 Date: Thu, 23 Nov 2023 09:16:50 +0200 Subject: [PATCH] glob --- Usage.md | 9 +++++++-- pr_agent/algo/file_filter.py | 7 ++++++- pr_agent/algo/utils.py | 2 +- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Usage.md b/Usage.md index f0b7071d..d4a7b230 100644 --- a/Usage.md +++ b/Usage.md @@ -37,9 +37,14 @@ To ignore files or directories, edit the **[ignore.toml](/pr_agent/settings/igno - `IGNORE.GLOB` - `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 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: diff --git a/pr_agent/algo/file_filter.py b/pr_agent/algo/file_filter.py index 32c61155..aa457293 100644 --- a/pr_agent/algo/file_filter.py +++ b/pr_agent/algo/file_filter.py @@ -11,7 +11,12 @@ def filter_ignored(files): try: # load regex patterns, and translate glob patterns to 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 compiled_patterns = [] diff --git a/pr_agent/algo/utils.py b/pr_agent/algo/utils.py index 3a555dca..d3377dee 100644 --- a/pr_agent/algo/utils.py +++ b/pr_agent/algo/utils.py @@ -282,7 +282,7 @@ def _fix_key_value(key: str, value: str): try: value = yaml.safe_load(value) 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