mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-12-12 02:45:18 +00:00
update
This commit is contained in:
parent
755165e90c
commit
6f7d81b086
2 changed files with 15 additions and 12 deletions
|
|
@ -583,7 +583,7 @@ class GitLabProvider(GitProvider):
|
|||
get_logger().warning(f"Failed to add eyes reaction, error: {e}")
|
||||
return None
|
||||
|
||||
def remove_reaction(self, issue_comment_id: int, reaction_id: int) -> bool:
|
||||
def remove_reaction(self, issue_comment_id: int, reaction_id: str) -> bool:
|
||||
try:
|
||||
if not self.id_mr:
|
||||
get_logger().warning("Cannot remove reaction: merge request ID is not set.")
|
||||
|
|
@ -596,13 +596,14 @@ class GitLabProvider(GitProvider):
|
|||
get_logger().warning(f"Comment with ID {issue_comment_id} not found in merge request {self.id_mr}.")
|
||||
return False
|
||||
|
||||
reaction = comment.awardemojis.get(reaction_id)
|
||||
if reaction:
|
||||
reaction.delete()
|
||||
return True
|
||||
else:
|
||||
get_logger().warning(f"Reaction with ID {reaction_id} not found in comment {issue_comment_id}.")
|
||||
return False
|
||||
reactions = comment.awardemojis.list()
|
||||
for reaction in reactions:
|
||||
if reaction.name == reaction_id:
|
||||
reaction.delete()
|
||||
return True
|
||||
|
||||
get_logger().warning(f"Reaction '{reaction_id}' not found in comment {issue_comment_id}.")
|
||||
return False
|
||||
except Exception as e:
|
||||
get_logger().warning(f"Failed to remove reaction, error: {e}")
|
||||
return False
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ from pr_agent.config_loader import get_settings, global_settings
|
|||
from pr_agent.git_providers.utils import apply_repo_settings
|
||||
from pr_agent.log import LoggingFormat, get_logger, setup_logger
|
||||
from pr_agent.secret_providers import get_secret_provider
|
||||
from pr_agent.git_providers import get_git_provider_with_context
|
||||
|
||||
setup_logger(fmt=LoggingFormat.JSON, level=get_settings().get("CONFIG.LOG_LEVEL", "DEBUG"))
|
||||
router = APIRouter()
|
||||
|
|
@ -25,15 +26,14 @@ router = APIRouter()
|
|||
secret_provider = get_secret_provider() if get_settings().get("CONFIG.SECRET_PROVIDER") else None
|
||||
|
||||
|
||||
async def handle_request(api_url: str, body: str, log_context: dict, sender_id: str):
|
||||
async def handle_request(api_url: str, body: str, log_context: dict, sender_id: str, notify=None):
|
||||
log_context["action"] = body
|
||||
log_context["event"] = "pull_request" if body == "/review" else "comment"
|
||||
log_context["api_url"] = api_url
|
||||
log_context["app_name"] = get_settings().get("CONFIG.APP_NAME", "Unknown")
|
||||
|
||||
with get_logger().contextualize(**log_context):
|
||||
await PRAgent().handle_request(api_url, body)
|
||||
|
||||
await PRAgent().handle_request(api_url, body, notify)
|
||||
|
||||
async def _perform_commands_gitlab(commands_conf: str, agent: PRAgent, api_url: str,
|
||||
log_context: dict, data: dict):
|
||||
|
|
@ -259,13 +259,15 @@ async def gitlab_webhook(background_tasks: BackgroundTasks, request: Request):
|
|||
if 'merge_request' in data:
|
||||
mr = data['merge_request']
|
||||
url = mr.get('url')
|
||||
comment_id = data.get('object_attributes', {}).get('id')
|
||||
provider = get_git_provider_with_context(pr_url=url)
|
||||
|
||||
get_logger().info(f"A comment has been added to a merge request: {url}")
|
||||
body = data.get('object_attributes', {}).get('note')
|
||||
if data.get('object_attributes', {}).get('type') == 'DiffNote' and '/ask' in body: # /ask_line
|
||||
body = handle_ask_line(body, data)
|
||||
|
||||
await handle_request(url, body, log_context, sender_id)
|
||||
await handle_request(url, body, log_context, sender_id, notify=lambda: provider.add_eyes_reaction(comment_id))
|
||||
|
||||
background_tasks.add_task(inner, request_json)
|
||||
end_time = datetime.now()
|
||||
|
|
|
|||
Loading…
Reference in a new issue