From 38f00386b4fa316eef426747d4bbd64a6e6b8dfb Mon Sep 17 00:00:00 2001 From: Simon Stamm Date: Thu, 8 May 2025 12:50:54 +0200 Subject: [PATCH] fix(gitlab): trigger when MR changes from draft to ready --- pr_agent/servers/gitlab_webhook.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/pr_agent/servers/gitlab_webhook.py b/pr_agent/servers/gitlab_webhook.py index 0aef933d..7a753c9e 100644 --- a/pr_agent/servers/gitlab_webhook.py +++ b/pr_agent/servers/gitlab_webhook.py @@ -86,9 +86,19 @@ def is_draft(data) -> bool: def is_draft_ready(data) -> bool: try: if 'draft' in data.get('changes', {}): - if data['changes']['draft']['previous'] == 'true' and data['changes']['draft']['current'] == 'false': + # Handle both boolean values and string values for compatibility + previous = data['changes']['draft']['previous'] + current = data['changes']['draft']['current'] + + # Convert to boolean if they're strings + if isinstance(previous, str): + previous = previous.lower() == 'true' + if isinstance(current, str): + current = current.lower() == 'true' + + if previous is True and current is False: return True - + # for gitlab server version before 16 elif 'title' in data.get('changes', {}): if 'Draft:' in data['changes']['title']['previous'] and 'Draft:' not in data['changes']['title']['current']: