Skip to content
| Marketplace
Sign in
Visual Studio Code>SCM Providers>Git Commit FormatterNew to Visual Studio Code? Get it now.
Git Commit Formatter

Git Commit Formatter

Git Commit Formatter

| (0) | Free
VSCode插件,用于格式化Git提交消息,自动添加类型前缀和任务编号
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Git Commit Formatter

VSCode插件,用于格式化Git提交消息,自动添加类型前缀和任务编号。

功能特点

  • 自动识别任务编号格式(如 "13386 主数据模型-主数据维护 : 主数据查询-多查询条件提升展示")
  • 重新格式化为 "fix(主数据模型-主数据维护) : 13386 主数据查询-多查询条件提升展示"
  • 提供提交类型选择(feat、fix、docs等)
  • 支持手动触发格式化
  • 自动检测符合格式的提交消息并提示格式化
  • 配置项控制是否开启自动格式化
  • 集成到VSCode的Git界面中

安装和使用

开发环境设置

  1. 克隆或下载项目到本地

  2. 在项目根目录运行:

    npm install
    npm run compile
    
  3. 按 F5 启动扩展开发主机进行测试

使用方法

  1. 自动格式化:当在Git提交输入框中输入符合格式的消息时,插件会自动提示格式化
  2. 手动格式化:使用命令面板 (Ctrl+Shift+P) 搜索 "格式化提交消息"
  3. 配置切换:点击状态栏中的格式化按钮或使用 "切换自动格式化" 命令

配置选项

  • gitCommitFormatter.autoFormat: 是否启用自动格式化 (默认: true)
  • gitCommitFormatter.defaultCommitType: 默认提交类型 (默认: "feat")
  • gitCommitFormatter.showTypeSelection: 是否显示类型选择对话框 (默认: true)

提交类型说明

  • feat: 新功能
  • fix: 修复bug
  • docs: 文档更新
  • style: 代码格式调整
  • refactor: 代码重构
  • perf: 性能优化
  • test: 测试相关
  • chore: 构建工具或辅助工具的变动

示例

输入:13386 主数据模型-主数据维护 : 主数据查询-多查询条件提升展示

选择类型:fix

输出:fix(主数据模型-主数据维护) : 13386 主数据查询-多查询条件提升展示

项目结构

├── src/
│   ├── extension.ts          # 扩展主入口
│   ├── commitFormatter.ts    # 核心格式化逻辑
│   ├── gitIntegration.ts     # Git集成
│   ├── ui.ts                 # 用户界面组件
│   └── test/                 # 测试文件
├── package.json              # 扩展清单
├── tsconfig.json            # TypeScript配置
└── README.md                # 说明文档

开发和测试

编译项目

npm run compile

监视模式编译

npm run watch

运行测试

npm test

调试扩展

  1. 在VSCode中打开项目
  2. 按 F5 启动扩展开发主机
  3. 在新窗口中测试扩展功能

技术实现

  • 使用TypeScript开发
  • 集成VSCode Git扩展API
  • 正则表达式模式匹配
  • 事件驱动的消息处理
  • 配置化的用户界面
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft