From d9d20d478dcf1a340e3205b63aaf2d6b7d6680b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=BB=BA=E5=B9=B3?= Date: Tue, 25 Feb 2025 15:53:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=91=BD=E4=BB=A4=E7=AE=A1?= =?UTF-8?q?=E7=90=86=EF=BC=8C=E6=8F=90=E5=8D=87=E7=B3=BB=E7=BB=9F=E7=9A=84?= =?UTF-8?q?=E6=98=93=E7=94=A8=E6=80=A7=E5=92=8C=E7=81=B5=E6=B4=BB=E6=80=A7?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/pr/migrations/0001_initial.py | 4 ++-- apps/pr/models.py | 2 +- apps/pr/views.py | 4 ++-- apps/utils/constant.py | 10 +++++----- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/apps/pr/migrations/0001_initial.py b/apps/pr/migrations/0001_initial.py index d92393c..fbe0be8 100644 --- a/apps/pr/migrations/0001_initial.py +++ b/apps/pr/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 5.1.6 on 2025-02-25 15:33 +# Generated by Django 5.1.6 on 2025-02-25 15:53 import django.db.models.deletion import simplepro.components.fields @@ -228,7 +228,7 @@ class Migration(migrations.Migration): ( "commands", simplepro.components.fields.CheckboxField( - default=["/review"], max_length=256, verbose_name="默认命令" + default="/review", max_length=256, verbose_name="默认命令" ), ), ( diff --git a/apps/pr/models.py b/apps/pr/models.py index fe42ecc..c7867f4 100644 --- a/apps/pr/models.py +++ b/apps/pr/models.py @@ -85,7 +85,7 @@ class ProjectConfig(BaseModel): ) commands = fields.CheckboxField( choices=constant.DEFAULT_COMMANDS, - default=["/review"], + default="/review", max_length=256, verbose_name="默认命令", ) diff --git a/apps/pr/views.py b/apps/pr/views.py index 22d2687..54b100e 100644 --- a/apps/pr/views.py +++ b/apps/pr/views.py @@ -56,7 +56,7 @@ class WebHookView(View): git_type = constant.GIT_TYPE[project_config.git_config.git_type][1] access_token = project_config.git_config.access_token project_secret = project_config.project_secret - project_commands = project_config.commands + project_commands = project_config.commands.split(",") config = load_project_config( git_url=git_url, @@ -100,7 +100,7 @@ class WebHookView(View): threads = [] for cmd in project_commands: - if cmd not in constant.DEFAULT_COMMANDS: + if cmd not in [cmd[1] for cmd in constant.DEFAULT_COMMANDS]: continue t = threading.Thread(target=run_cmd, args=(cmd,)) threads.append(t) diff --git a/apps/utils/constant.py b/apps/utils/constant.py index b112655..c8b0ee4 100644 --- a/apps/utils/constant.py +++ b/apps/utils/constant.py @@ -4,8 +4,8 @@ GIT_TYPE = ( (2, "gitea") ) -DEFAULT_COMMANDS = [ - "/review", - "/describe", - "/improve_code" -] +DEFAULT_COMMANDS = ( + ("/review", "/review"), + ("/describe", "/describe"), + ("/improve_code", "/improve_code"), +)