优化git类型管理,提升代码可读性与性能。
This commit is contained in:
parent
551c76db8b
commit
f597e928f6
@ -1,260 +0,0 @@
|
|||||||
# Generated by Django 5.1.6 on 2025-02-25 13:55
|
|
||||||
|
|
||||||
import django.db.models.deletion
|
|
||||||
import simplepro.components.fields
|
|
||||||
import uuid
|
|
||||||
from django.db import migrations, models
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
initial = True
|
|
||||||
|
|
||||||
dependencies = []
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.CreateModel(
|
|
||||||
name="AIConfig",
|
|
||||||
fields=[
|
|
||||||
("id", models.BigAutoField(primary_key=True, serialize=False)),
|
|
||||||
(
|
|
||||||
"uid",
|
|
||||||
models.UUIDField(
|
|
||||||
db_index=True,
|
|
||||||
default=uuid.uuid4,
|
|
||||||
editable=False,
|
|
||||||
verbose_name="UUID",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"create_at",
|
|
||||||
simplepro.components.fields.DateTimeField(
|
|
||||||
auto_now_add=True, db_index=True, verbose_name="创建时间"
|
|
||||||
),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"update_at",
|
|
||||||
simplepro.components.fields.DateTimeField(
|
|
||||||
auto_now=True, verbose_name="更新时间"
|
|
||||||
),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"delete_at",
|
|
||||||
simplepro.components.fields.DateTimeField(
|
|
||||||
blank=True, null=True, verbose_name="删除时间"
|
|
||||||
),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"create_by",
|
|
||||||
simplepro.components.fields.CharField(
|
|
||||||
blank=True, max_length=32, null=True, verbose_name="创建人"
|
|
||||||
),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"detail",
|
|
||||||
simplepro.components.fields.CharField(
|
|
||||||
blank=True, max_length=200, null=True, verbose_name="备注信息"
|
|
||||||
),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"api_base",
|
|
||||||
simplepro.components.fields.CharField(
|
|
||||||
blank=True, max_length=128, null=True, verbose_name="API(代理)地址"
|
|
||||||
),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"api_key",
|
|
||||||
simplepro.components.fields.CharField(
|
|
||||||
blank=True, max_length=128, null=True, verbose_name="API密钥"
|
|
||||||
),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"llm_model",
|
|
||||||
simplepro.components.fields.CharField(
|
|
||||||
blank=True, max_length=16, null=True, verbose_name="LLM模型"
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
options={
|
|
||||||
"verbose_name": "AI模型配置",
|
|
||||||
"verbose_name_plural": "AI模型配置",
|
|
||||||
},
|
|
||||||
),
|
|
||||||
migrations.CreateModel(
|
|
||||||
name="GitConfig",
|
|
||||||
fields=[
|
|
||||||
("id", models.BigAutoField(primary_key=True, serialize=False)),
|
|
||||||
(
|
|
||||||
"uid",
|
|
||||||
models.UUIDField(
|
|
||||||
db_index=True,
|
|
||||||
default=uuid.uuid4,
|
|
||||||
editable=False,
|
|
||||||
verbose_name="UUID",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"create_at",
|
|
||||||
simplepro.components.fields.DateTimeField(
|
|
||||||
auto_now_add=True, db_index=True, verbose_name="创建时间"
|
|
||||||
),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"update_at",
|
|
||||||
simplepro.components.fields.DateTimeField(
|
|
||||||
auto_now=True, verbose_name="更新时间"
|
|
||||||
),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"delete_at",
|
|
||||||
simplepro.components.fields.DateTimeField(
|
|
||||||
blank=True, null=True, verbose_name="删除时间"
|
|
||||||
),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"create_by",
|
|
||||||
simplepro.components.fields.CharField(
|
|
||||||
blank=True, max_length=32, null=True, verbose_name="创建人"
|
|
||||||
),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"detail",
|
|
||||||
simplepro.components.fields.CharField(
|
|
||||||
blank=True, max_length=200, null=True, verbose_name="备注信息"
|
|
||||||
),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"git_name",
|
|
||||||
simplepro.components.fields.CharField(
|
|
||||||
blank=True, max_length=16, null=True, verbose_name="Git名称"
|
|
||||||
),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"git_type",
|
|
||||||
simplepro.components.fields.RadioField(
|
|
||||||
choices=[
|
|
||||||
("gitlab", "gitlab"),
|
|
||||||
("github", "github"),
|
|
||||||
("gitea", "gitea"),
|
|
||||||
],
|
|
||||||
default="gitlab",
|
|
||||||
verbose_name="Git类型",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"git_url",
|
|
||||||
simplepro.components.fields.CharField(
|
|
||||||
blank=True, max_length=128, null=True, verbose_name="Git地址"
|
|
||||||
),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"access_token",
|
|
||||||
simplepro.components.fields.CharField(
|
|
||||||
blank=True, max_length=128, null=True, verbose_name="访问密钥"
|
|
||||||
),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"pr_ai",
|
|
||||||
simplepro.components.fields.ForeignKey(
|
|
||||||
blank=True,
|
|
||||||
null=True,
|
|
||||||
on_delete=django.db.models.deletion.SET_NULL,
|
|
||||||
to="pr.aiconfig",
|
|
||||||
verbose_name="AI模型",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
options={
|
|
||||||
"verbose_name": "Git服务配置",
|
|
||||||
"verbose_name_plural": "Git服务配置",
|
|
||||||
},
|
|
||||||
),
|
|
||||||
migrations.CreateModel(
|
|
||||||
name="ProjectConfig",
|
|
||||||
fields=[
|
|
||||||
("id", models.BigAutoField(primary_key=True, serialize=False)),
|
|
||||||
(
|
|
||||||
"uid",
|
|
||||||
models.UUIDField(
|
|
||||||
db_index=True,
|
|
||||||
default=uuid.uuid4,
|
|
||||||
editable=False,
|
|
||||||
verbose_name="UUID",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"create_at",
|
|
||||||
simplepro.components.fields.DateTimeField(
|
|
||||||
auto_now_add=True, db_index=True, verbose_name="创建时间"
|
|
||||||
),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"update_at",
|
|
||||||
simplepro.components.fields.DateTimeField(
|
|
||||||
auto_now=True, verbose_name="更新时间"
|
|
||||||
),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"delete_at",
|
|
||||||
simplepro.components.fields.DateTimeField(
|
|
||||||
blank=True, null=True, verbose_name="删除时间"
|
|
||||||
),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"create_by",
|
|
||||||
simplepro.components.fields.CharField(
|
|
||||||
blank=True, max_length=32, null=True, verbose_name="创建人"
|
|
||||||
),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"detail",
|
|
||||||
simplepro.components.fields.CharField(
|
|
||||||
blank=True, max_length=200, null=True, verbose_name="备注信息"
|
|
||||||
),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"project_id",
|
|
||||||
simplepro.components.fields.CharField(
|
|
||||||
blank=True, max_length=8, null=True, verbose_name="项目ID"
|
|
||||||
),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"project_name",
|
|
||||||
simplepro.components.fields.CharField(
|
|
||||||
blank=True, max_length=16, null=True, verbose_name="项目名称"
|
|
||||||
),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"project_secret",
|
|
||||||
simplepro.components.fields.CharField(
|
|
||||||
blank=True, max_length=128, null=True, verbose_name="项目密钥"
|
|
||||||
),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"commands",
|
|
||||||
simplepro.components.fields.CheckboxField(
|
|
||||||
default=["/review"], max_length=256, verbose_name="默认命令"
|
|
||||||
),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"is_enable",
|
|
||||||
simplepro.components.fields.SwitchField(
|
|
||||||
default=True, verbose_name="是否启用"
|
|
||||||
),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"git_config",
|
|
||||||
simplepro.components.fields.ForeignKey(
|
|
||||||
blank=True,
|
|
||||||
null=True,
|
|
||||||
on_delete=django.db.models.deletion.SET_NULL,
|
|
||||||
to="pr.gitconfig",
|
|
||||||
verbose_name="Git配置",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
options={
|
|
||||||
"verbose_name": "项目配置",
|
|
||||||
"verbose_name_plural": "项目配置",
|
|
||||||
},
|
|
||||||
),
|
|
||||||
]
|
|
||||||
@ -45,7 +45,7 @@ class GitConfig(BaseModel):
|
|||||||
)
|
)
|
||||||
git_type = fields.RadioField(
|
git_type = fields.RadioField(
|
||||||
choices=constant.GIT_TYPE,
|
choices=constant.GIT_TYPE,
|
||||||
default="gitlab",
|
default=0,
|
||||||
verbose_name="Git类型"
|
verbose_name="Git类型"
|
||||||
)
|
)
|
||||||
git_url = fields.CharField(
|
git_url = fields.CharField(
|
||||||
|
|||||||
@ -53,7 +53,7 @@ class WebHookView(View):
|
|||||||
model = project_config.git_config.pr_ai.llm_model
|
model = project_config.git_config.pr_ai.llm_model
|
||||||
# Git服务器配置
|
# Git服务器配置
|
||||||
git_url = project_config.git_config.git_url
|
git_url = project_config.git_config.git_url
|
||||||
git_type = project_config.git_config.git_type
|
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
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
GIT_TYPE = (
|
GIT_TYPE = (
|
||||||
("gitlab", "gitlab"),
|
(0, "gitlab"),
|
||||||
("github", "github"),
|
(1, "github"),
|
||||||
("gitea", "gitea")
|
(2, "gitea")
|
||||||
)
|
)
|
||||||
|
|
||||||
DEFAULT_COMMANDS = [
|
DEFAULT_COMMANDS = [
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user