Adds an option to ignore PR opens by regex matching

This commit is contained in:
Ori Kotek
2024-02-22 12:14:04 +02:00
parent 42bcda1eb8
commit e3dba12fea
2 changed files with 9 additions and 0 deletions

View File

@ -1,6 +1,7 @@
import copy import copy
import os import os
import asyncio.locks import asyncio.locks
import re
from typing import Any, Dict, List, Tuple from typing import Any, Dict, List, Tuple
import uvicorn import uvicorn
@ -127,6 +128,13 @@ async def handle_request(body: Dict[str, Any], event: str):
# automatically review opened/reopened/ready_for_review PRs as long as they're not in draft, # automatically review opened/reopened/ready_for_review PRs as long as they're not in draft,
# as well as direct review requests from the bot # as well as direct review requests from the bot
elif event == 'pull_request' and action != 'synchronize': elif event == 'pull_request' and action != 'synchronize':
title = body.get("pull_request", {}).get("title", "")
ignore_pr_title_re = get_settings().get("GITHUB_APP.IGNORE_PR_TITLE", [])
if not isinstance(ignore_pr_title_re, list):
ignore_pr_title_re = [ignore_pr_title_re]
if ignore_pr_title_re and any(re.search(regex, title) for regex in ignore_pr_title_re):
get_logger().info(f"Ignoring PR with title '{title}' due to github_app.ignore_pr_title setting")
return {}
pull_request, api_url = _check_pull_request_event(action, body, log_context, bot_user) pull_request, api_url = _check_pull_request_event(action, body, log_context, bot_user)
if not (pull_request and api_url): if not (pull_request and api_url):
return {} return {}

View File

@ -169,6 +169,7 @@ push_commands = [
--pr_reviewer.extra_instructions='' \ --pr_reviewer.extra_instructions='' \
""" """
] ]
ignore_pr_title = []
[gitlab] [gitlab]
url = "https://gitlab.com" # URL to the gitlab service url = "https://gitlab.com" # URL to the gitlab service