避免重复写入pr历史数据

This commit is contained in:
张建平 2025-04-23 15:31:59 +08:00
parent b556dc943e
commit 451a6d8b42

View File

@ -143,19 +143,20 @@ class GitLabProvider(GitProvider):
if request_data.get('object_attributes', {}).get( if request_data.get('object_attributes', {}).get(
"source_branch" "source_branch"
) and request_data.get('object_attributes', {}).get("target_branch"): ) and request_data.get('object_attributes', {}).get("target_branch"):
models.ProjectHistory.objects.create( if not models.ProjectHistory.objects.filter(project_id=project_id, mr_url=request_data.get('object_attributes', {}).get("url")).exists():
project_id=project_id, models.ProjectHistory.objects.create(
project_url=request_data.get("project", {}).get("web_url"), project_id=project_id,
mr_url=request_data.get('object_attributes', {}).get("url"), project_url=request_data.get("project", {}).get("web_url"),
source_branch=request_data.get('object_attributes', {}).get( mr_url=request_data.get('object_attributes', {}).get("url"),
"source_branch" source_branch=request_data.get('object_attributes', {}).get(
), "source_branch"
target_branch=request_data.get('object_attributes', {}).get( ),
"target_branch" target_branch=request_data.get('object_attributes', {}).get(
), "target_branch"
mr_title=request_data.get('object_attributes', {}).get("title"), ),
source_data=request_data, mr_title=request_data.get('object_attributes', {}).get("title"),
) source_data=request_data,
)
def run_command(self, mr_url, project_commands): def run_command(self, mr_url, project_commands):
""" """