mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-07-03 20:30:41 +08:00
Add file ignore functionality and update documentation for ignore patterns
This commit is contained in:
@ -10,12 +10,17 @@ To ignore files or directories, edit the **[ignore.toml](https://github.com/Codi
|
|||||||
For example, to ignore Python files in a PR with online usage, comment on a PR:
|
For example, to ignore Python files in a PR with online usage, comment on a PR:
|
||||||
`/review --ignore.glob=['*.py']`
|
`/review --ignore.glob=['*.py']`
|
||||||
|
|
||||||
To ignore Python files in all PRs, set in a configuration file:
|
To ignore Python files in all PRs using `glob` pattern, set in a configuration file:
|
||||||
```
|
```
|
||||||
[ignore]
|
[ignore]
|
||||||
glob = ['*.py']
|
glob = ['*.py']
|
||||||
```
|
```
|
||||||
|
|
||||||
|
And to ignore Python files in all PRs using `regex` pattern, set in a configuration file:
|
||||||
|
```
|
||||||
|
[regex]
|
||||||
|
regex = ['.*\.py$']
|
||||||
|
```
|
||||||
## Extra instructions
|
## Extra instructions
|
||||||
|
|
||||||
All PR-Agent tools have a parameter called `extra_instructions`, that enables to add free-text extra instructions. Example usage:
|
All PR-Agent tools have a parameter called `extra_instructions`, that enables to add free-text extra instructions. Example usage:
|
||||||
|
@ -8,6 +8,7 @@ from github import AppAuthentication, Auth, Github, GithubException
|
|||||||
from retry import retry
|
from retry import retry
|
||||||
from starlette_context import context
|
from starlette_context import context
|
||||||
|
|
||||||
|
from ..algo.file_filter import filter_ignored
|
||||||
from ..algo.language_handler import is_valid_file
|
from ..algo.language_handler import is_valid_file
|
||||||
from ..algo.utils import load_large_diff, clip_tokens, find_line_number_of_relevant_line_in_file
|
from ..algo.utils import load_large_diff, clip_tokens, find_line_number_of_relevant_line_in_file
|
||||||
from ..config_loader import get_settings
|
from ..config_loader import get_settings
|
||||||
@ -106,19 +107,22 @@ class GithubProvider(GitProvider):
|
|||||||
git_files = context.get("git_files", None)
|
git_files = context.get("git_files", None)
|
||||||
if git_files:
|
if git_files:
|
||||||
return git_files
|
return git_files
|
||||||
self.git_files = self.pr.get_files()
|
self.git_files = list(self.pr.get_files()) # 'list' to hanlde pagination
|
||||||
context["git_files"] = self.git_files
|
context["git_files"] = self.git_files
|
||||||
return self.git_files
|
return self.git_files
|
||||||
except Exception:
|
except Exception:
|
||||||
if not self.git_files:
|
if not self.git_files:
|
||||||
self.git_files = self.pr.get_files()
|
self.git_files = list(self.pr.get_files())
|
||||||
return self.git_files
|
return self.git_files
|
||||||
|
|
||||||
def get_num_of_files(self):
|
def get_num_of_files(self):
|
||||||
if self.git_files:
|
if hasattr(self.git_files, "totalCount"):
|
||||||
return self.git_files.totalCount
|
return self.git_files.totalCount
|
||||||
else:
|
else:
|
||||||
return -1
|
try:
|
||||||
|
return len(self.git_files)
|
||||||
|
except Exception as e:
|
||||||
|
return -1
|
||||||
|
|
||||||
@retry(exceptions=RateLimitExceeded,
|
@retry(exceptions=RateLimitExceeded,
|
||||||
tries=get_settings().github.ratelimit_retries, delay=2, backoff=2, jitter=(1, 3))
|
tries=get_settings().github.ratelimit_retries, delay=2, backoff=2, jitter=(1, 3))
|
||||||
@ -143,6 +147,7 @@ class GithubProvider(GitProvider):
|
|||||||
return self.diff_files
|
return self.diff_files
|
||||||
|
|
||||||
files = self.get_files()
|
files = self.get_files()
|
||||||
|
files = filter_ignored(files)
|
||||||
diff_files = []
|
diff_files = []
|
||||||
|
|
||||||
for file in files:
|
for file in files:
|
||||||
|
@ -8,4 +8,5 @@ glob = [
|
|||||||
regex = [
|
regex = [
|
||||||
# Ignore files and directories matching these regex patterns.
|
# Ignore files and directories matching these regex patterns.
|
||||||
# See https://learnbyexample.github.io/python-regex-cheatsheet/
|
# See https://learnbyexample.github.io/python-regex-cheatsheet/
|
||||||
|
# for example: regex = ['.*\.toml$']
|
||||||
]
|
]
|
||||||
|
Reference in New Issue
Block a user