Git Hooks 配置结构
gvt hook 通过 .gvt/hook/ 目录管理检查配置,按模块拆分独立 .toml。
目录布局
.gvt/hook/
├── config.toml # 全局开关(可选)
├── backend/
│ └── backend.toml # Go 后端
├── frontend/
│ ├── admin.toml # 管理后台
│ └── portal.toml # 门户前端
├── docs/
│ └── docs.toml # 文档
└── modules/
└── <name>.toml # gvt add 注册的动态模块全局配置
.gvt/hook/config.toml:
toml
# false 时跳过所有检查
enabled = true模块配置
.gvt/hook/backend/backend.toml:
toml
enabled = true
dir = "."
warn_lines = 250
max_lines = 300
checks = ["line_count", "go_vet", "go_build", "staticcheck"]字段说明
| 字段 | 说明 |
|---|---|
enabled | 是否启用该模块检查 |
dir | 检查根目录(相对模块 .toml 所在目录) |
warn_lines | 行数警告阈值 |
max_lines | 行数错误阈值(超限则失败) |
checks | 检查项列表(可任意组合) |
动态模块(gvt add)
使用 gvt add --dir <path> 注册任意目录,自动检测工具链并写为 .gvt/hook/modules/<name>.toml。文件名由路径推导:
.→ 项目名- 多层路径用
-连接,如frontend/my-app→frontend-my-app
注意事项
- 每个模块独立
enabled开关,可单独关闭某目录检查。 - 修改配置后无需重启,下次
gvt hook自动读取最新内容。