优化命令管理,提升系统的易用性和灵活性。

This commit is contained in:
张建平 2025-02-25 15:53:47 +08:00
parent d67261223a
commit d9d20d478d
4 changed files with 10 additions and 10 deletions

View File

@ -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 django.db.models.deletion
import simplepro.components.fields import simplepro.components.fields
@ -228,7 +228,7 @@ class Migration(migrations.Migration):
( (
"commands", "commands",
simplepro.components.fields.CheckboxField( simplepro.components.fields.CheckboxField(
default=["/review"], max_length=256, verbose_name="默认命令" default="/review", max_length=256, verbose_name="默认命令"
), ),
), ),
( (

View File

@ -85,7 +85,7 @@ class ProjectConfig(BaseModel):
) )
commands = fields.CheckboxField( commands = fields.CheckboxField(
choices=constant.DEFAULT_COMMANDS, choices=constant.DEFAULT_COMMANDS,
default=["/review"], default="/review",
max_length=256, max_length=256,
verbose_name="默认命令", verbose_name="默认命令",
) )

View File

@ -56,7 +56,7 @@ class WebHookView(View):
git_type = constant.GIT_TYPE[project_config.git_config.git_type][1] git_type = constant.GIT_TYPE[project_config.git_config.git_type][1]
access_token = project_config.git_config.access_token access_token = project_config.git_config.access_token
project_secret = project_config.project_secret project_secret = project_config.project_secret
project_commands = project_config.commands project_commands = project_config.commands.split(",")
config = load_project_config( config = load_project_config(
git_url=git_url, git_url=git_url,
@ -100,7 +100,7 @@ class WebHookView(View):
threads = [] threads = []
for cmd in project_commands: 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 continue
t = threading.Thread(target=run_cmd, args=(cmd,)) t = threading.Thread(target=run_cmd, args=(cmd,))
threads.append(t) threads.append(t)

View File

@ -4,8 +4,8 @@ GIT_TYPE = (
(2, "gitea") (2, "gitea")
) )
DEFAULT_COMMANDS = [ DEFAULT_COMMANDS = (
"/review", ("/review", "/review"),
"/describe", ("/describe", "/describe"),
"/improve_code" ("/improve_code", "/improve_code"),
] )