Skip to content

VS Code Commit Message Editor 中文配置指南

1. 概述

本文档提供了一套适用于使用 禅道(Zentao) 进行项目管理的开发团队的 VS Code 提交信息模板配置。该配置通过 Commit Message Editor 插件实现,将提交类型、描述及禅道任务/缺陷编号结构化整合,提升 Git 提交信息的规范性与可追溯性。


2. 配置文件内容

json
{
  "$schema": "https://bendera.github.io/vscode-commit-message-editor/schemas/config-v1.schema.json",
  "configVersion": "1",
  "staticTemplate": [
    "feat: 简要描述 #zentao-id"
  ],
  "dynamicTemplate": [
    "{type}: {description} {zentao_type}{zentao_id}"
  ],
  "tokens": [
    {
      "label": "类型",
      "name": "type",
      "type": "enum",
      "description": "本次提交的变更类型",
      "options": [
        {
          "label": "chore",
          "description": "更新构建脚本、依赖或工具配置等,不涉及生产代码变更"
        },
        {
          "label": "docs",
          "description": "仅文档内容的修改(如注释、README、用户手册等)"
        },
        {
          "label": "feat",
          "description": "新增功能或特性"
        },
        {
          "label": "fix",
          "description": "修复缺陷或问题"
        },
        {
          "label": "perf",
          "description": "提升性能的代码优化(如算法改进、减少资源消耗等)"
        },
        {
          "label": "refactor",
          "description": "代码重构(既未修复 bug,也未新增功能,仅改善结构或可读性)"
        },
        {
          "label": "style",
          "description": "不影响代码逻辑的格式调整(如空格、缩进、分号、换行等)"
        },
        {
          "label": "test",
          "description": "补充缺失的测试用例或修正现有测试"
        }
      ]
    },
    {
      "label": "简要描述",
      "name": "description",
      "description": "在主题行中简明扼要地描述本次变更(建议使用动词开头,如“添加”、“修复”、“优化”)",
      "type": "text",
      "multiline": false
    },
    {
      "label": "禅道类型",
      "name": "zentao_type",
      "type": "enum",
      "options": [
        {
          "label": "task",
          "value": "#task-",
          "description": "关联禅道任务"
        },
        {
          "label": "bug",
          "value": "#bug-",
          "description": "关联禅道缺陷"
        },
        {
          "label": "---",
          "value": "",
          "description": "无对应的禅道编号"
        }
      ]
    },
    {
      "label": "禅道ID",
      "name": "zentao_id",
      "type": "text",
      "description": "填写禅道中的任务或缺陷编号(如 12345)"
    }
  ]
}

3. 使用说明

3.1 安装前提

3.2 配置部署

将上述 JSON 内容保存为项目根目录下的:

.vscode/commit-message-editor.json

3.3 提交示例

配置生效后,生成的提交信息格式如下:

  • 功能开发

    text
    feat: 添加用户登录接口 #task-1001
  • 缺陷修复

    text
    fix: 修复订单状态显示错误 #bug-2048
  • 无关联项

    text
    docs: 更新 API 接口文档

4. 自定义建议

  • 精简类型:若团队不常用 perftest,可从 typeoptions 中移除对应项。
  • 适配其他工具:如需支持 Jira、TAPD 等,可修改 zentao_type 字段的 value 格式(如 JIRA-TAPD#)。
  • 多语言切换:当前配置为中文,如需英文环境,可保留原始英文描述字段。

提示:所有提示文本均为中文,便于国内开发者快速理解并遵循提交规范,减少沟通成本。

基于 VitePress 构建