This commit is contained in:
sophie committed 2026-05-21 11:38:54 +08:00
1 parent a6f35b375c
commit b1613824ce
8 files changed
+200 -12

No files matched your search

+31 -2
View File
@@ -48,6 +48,7 @@
4. 提交信息建议规范化:`feat:`、`fix:`、`refactor:`、`docs:`、`chore:`
5. 合并前必须完成最少检查:
- 能启动前后端
- 改动了 `frontend/` 时本地 `cd frontend && npm run build` 通过(或已安装 Git Hooks,由 pre-push 自动检查)
- 关键页面可访问
- 登录流程可用
6. 任何涉及数据库结构变更的提交,必须包含迁移脚本或升级说明
@@ -62,7 +63,35 @@ git clone https://gitee.com/justop/hxops.git
cd hxops
```
### 4.2 常用 Git 操作示例
### 4.2 安装 Git Hooks(推荐,每人 clone 后执行一次)
仓库根目录的 `.githooks/` 会随代码拉取;**不会自动生效**,需在本机启用:
| Hook | 时机 | 检查内容 |
|------|------|----------|
| `pre-commit` | `git commit` | 改 `models.py` 须同时提交 migration;暂存 `frontend/` 时跑 `vue-tsc` |
| `pre-push` | `git push` | 本次推送含 `frontend/` 变更时跑 `npm run build`(与 Jenkins 部署一致) |
**Git Bash / WSL:**
```bash
chmod +x scripts/install_git_hooks.sh .githooks/pre-commit .githooks/pre-push
./scripts/install_git_hooks.sh
```
**PowerShell(仅启用钩子目录):**
```powershell
git config core.hooksPath .githooks
```
验证:`git config --get core.hooksPath` 应输出 `.githooks`。
前置:已执行 `cd frontend && npm install`。应急跳过前端检查:`$env:SKIP_FRONTEND_HOOKS="1"`(bash 为 `SKIP_FRONTEND_HOOKS=1`)。
Jenkins 在检测到 `frontend/` 变更时会再跑一遍同款构建(`scripts/ci_frontend_build.sh`),作为 Hook 被跳过时的兜底。
### 4.3 常用 Git 操作示例
```bash
# 拉取远程分支
@@ -81,7 +110,7 @@ git commit -m "feat: your change summary"
git push origin feature/your-feature-name
```
### 4.3 关键目录
### 4.4 关键目录
- `frontend/`:Vue 3 + TypeScript + Vite
- `backend/`:Flask + SQLAlchemy + Flask-Migrate