From 451a6d8b42d968c40a472d26cdb50c0d33487e55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=BB=BA=E5=B9=B3?= Date: Wed, 23 Apr 2025 15:31:59 +0800 Subject: [PATCH] =?UTF-8?q?=E9=81=BF=E5=85=8D=E9=87=8D=E5=A4=8D=E5=86=99?= =?UTF-8?q?=E5=85=A5pr=E5=8E=86=E5=8F=B2=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/utils/git_config.py | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/apps/utils/git_config.py b/apps/utils/git_config.py index e63e7a3..a1af154 100644 --- a/apps/utils/git_config.py +++ b/apps/utils/git_config.py @@ -143,19 +143,20 @@ class GitLabProvider(GitProvider): if request_data.get('object_attributes', {}).get( "source_branch" ) and request_data.get('object_attributes', {}).get("target_branch"): - models.ProjectHistory.objects.create( - project_id=project_id, - project_url=request_data.get("project", {}).get("web_url"), - mr_url=request_data.get('object_attributes', {}).get("url"), - source_branch=request_data.get('object_attributes', {}).get( - "source_branch" - ), - target_branch=request_data.get('object_attributes', {}).get( - "target_branch" - ), - mr_title=request_data.get('object_attributes', {}).get("title"), - source_data=request_data, - ) + if not models.ProjectHistory.objects.filter(project_id=project_id, mr_url=request_data.get('object_attributes', {}).get("url")).exists(): + models.ProjectHistory.objects.create( + project_id=project_id, + project_url=request_data.get("project", {}).get("web_url"), + mr_url=request_data.get('object_attributes', {}).get("url"), + source_branch=request_data.get('object_attributes', {}).get( + "source_branch" + ), + target_branch=request_data.get('object_attributes', {}).get( + "target_branch" + ), + mr_title=request_data.get('object_attributes', {}).get("title"), + source_data=request_data, + ) def run_command(self, mr_url, project_commands): """