Bitbucket server filter out globally ignored files before attempting diff

This commit is contained in:
MarkRx
2024-05-30 11:34:39 -04:00
parent 04d55a6309
commit c11ee8643e
2 changed files with 8 additions and 1 deletions

4
.gitignore vendored
View File

@ -1,4 +1,6 @@
.idea/ .idea/
.lsp/
.vscode/
venv/ venv/
pr_agent/settings/.secrets.toml pr_agent/settings/.secrets.toml
__pycache__ __pycache__
@ -6,4 +8,4 @@ dist/
*.egg-info/ *.egg-info/
build/ build/
.DS_Store .DS_Store
docs/.cache/ docs/.cache/

View File

@ -8,6 +8,7 @@ from starlette_context import context
from .git_provider import GitProvider from .git_provider import GitProvider
from pr_agent.algo.types import FilePatchInfo from pr_agent.algo.types import FilePatchInfo
from ..algo.language_handler import is_valid_file
from ..algo.utils import load_large_diff, find_line_number_of_relevant_line_in_file from ..algo.utils import load_large_diff, find_line_number_of_relevant_line_in_file
from ..config_loader import get_settings from ..config_loader import get_settings
from ..log import get_logger from ..log import get_logger
@ -156,6 +157,10 @@ class BitbucketServerProvider(GitProvider):
changes = self.bitbucket_client.get_pull_requests_changes(self.workspace_slug, self.repo_slug, self.pr_num) changes = self.bitbucket_client.get_pull_requests_changes(self.workspace_slug, self.repo_slug, self.pr_num)
for change in changes: for change in changes:
file_path = change['path']['toString'] file_path = change['path']['toString']
if not is_valid_file(file_path.split("/")[-1]):
get_logger().info(f"Skipping a non-code file: {file_path}")
continue
match change['type']: match change['type']:
case 'ADD': case 'ADD':
edit_type = EDIT_TYPE.ADDED edit_type = EDIT_TYPE.ADDED