Merge pull request #1914 from abhinav-1305/fix/gitlab-webhook

apply repository settings before processing push commands in GitLab webhook
This commit is contained in:
Tal
2025-07-05 09:08:57 +03:00
committed by GitHub
4 changed files with 9 additions and 15 deletions

View File

@ -234,6 +234,9 @@ async def gitlab_webhook(background_tasks: BackgroundTasks, request: Request):
get_logger().info(f"Skipping draft MR: {url}")
return JSONResponse(status_code=status.HTTP_200_OK, content=jsonable_encoder({"message": "success"}))
# Apply repo settings before checking push commands or handle_push_trigger
apply_repo_settings(url)
commands_on_push = get_settings().get(f"gitlab.push_commands", {})
handle_push_trigger = get_settings().get(f"gitlab.handle_push_trigger", False)
if not commands_on_push or not handle_push_trigger:
@ -282,8 +285,8 @@ def handle_ask_line(body, data):
question = body.replace('/ask', '').strip()
path = data['object_attributes']['position']['new_path']
side = 'RIGHT' # if line_range_['start']['type'] == 'new' else 'LEFT'
comment_id = data['object_attributes']["discussion_id"]
get_logger().info("Handling line comment")
_id = data['object_attributes']["discussion_id"]
get_logger().info("Handling line ")
body = f"/ask_line --line_start={start_line} --line_end={end_line} --side={side} --file_name={path} --comment_id={comment_id} {question}"
except Exception as e:
get_logger().error(f"Failed to handle ask line comment: {e}")