# Hướng Dẫn Đóng Góp ## Kỷ Luật Commit & Push (Bắt Buộc) > Để tránh conflict khi nhiều agent/engineer làm việc song song, toàn bộ team PHẢI tuân thủ các quy định sau. Nguồn: [GOO-91](/GOO/issues/GOO-91) (chỉ thị từ CEO qua [GOO-88](/GOO/issues/GOO-88)). 1. **Commit ngay khi hoàn thành task** — mỗi task = một commit (hoặc một chuỗi commit nhỏ liên quan). Không gom nhiều task không liên quan vào một commit lớn. 2. **Pull/rebase trước khi push** — luôn chạy `git pull --rebase origin ` trước `git push` để giảm merge conflict. 3. **Push ngay sau commit** — không giữ commit local quá 1 ngày làm việc. Commit không push = rủi ro mất việc + conflict tăng. 4. **Conventional Commits** — bắt buộc (`feat:`, `fix:`, `chore:`, `refactor:`, `docs:`, `test:`, `style:`, `perf:`). Xem [Quy Ước Commit](#quy-ước-commit) bên dưới. 5. **KHÔNG push trực tiếp lên `main` / `master`** — luôn dùng feature branch + Pull Request. Branch chính được bảo vệ bằng GitHub branch protection rules. 6. **PR phải pass CI** (`lint` → `typecheck` → `test` → `build`) trước khi merge. PR đỏ CI không được merge dù đã approve. 7. **Squash-merge khi merge PR** — giữ history trên `main` sạch, mỗi PR = một commit logic. 8. **Xóa feature branch sau khi merge** — tránh branch sprawl. GitHub có auto-delete branch sau merge; bật nó trong repo settings. ### Flow nhanh cho mỗi task ```bash # 1. Tạo/chuyển sang feature branch (KHÔNG commit trực tiếp vào main) git checkout -b feature/goo-xx-short-description # 2. Làm việc, khi hoàn thành task: git add git commit -m "feat(scope): mô tả ngắn" # 3. Đồng bộ & push git pull --rebase origin main # hoặc develop git push -u origin feature/goo-xx-short-description # 4. Mở PR, chờ CI xanh + review, squash-merge, xóa branch ``` --- ## Quy Trình Git & Branching ### Nhánh Chính | Nhánh | Mục đích | Protected | |-------|---------|-----------| | `main` / `master` | Production branch — stable releases | ✅ Yes | | `develop` | Development branch — integration point | ✅ Yes | | `feature/*` | Feature branches — phát triển tính năng mới | ❌ No | | `fix/*` | Bug fix branches | ❌ No | | `docs/*` | Documentation updates | ❌ No | | `refactor/*` | Code refactoring, cleanup | ❌ No | ### Quy Trình Tạo Feature Branch ```bash # 1. Cập nhật branch chính git checkout develop git pull origin develop # 2. Tạo feature branch git checkout -b feature/awesome-feature # Naming convention: # feature/user-authentication # fix/csrf-middleware-double-middleware # docs/api-documentation # refactor/remove-dead-code ``` ### Pull Request Workflow ```bash # 1. Commit changes git add . git commit -m "feat(auth): implement phone OTP login" # 2. Push to origin git push origin feature/awesome-feature # 3. Open PR on GitHub # - Title: Short summary (max 70 chars) # - Description: Why, what changed, how to test # - Link related issues: Fixes #GOO-7 # - Request reviewers: team lead, domain expert # 4. Address review feedback git add . git commit -m "refactor(auth): address PR feedback" git push # 5. Merge when approved # - Squash commits if many small fixes # - Delete branch after merge ``` ### Protected Branch Rules `main` và `develop` branches yêu cầu: - ✅ All CI checks pass (lint, typecheck, test, build) - ✅ 1 approval từ code owner - ✅ Dismiss stale PR approvals - ✅ Branches must be up to date before merge - ❌ Force push không được phép --- ## Quy Ước Commit Theo chuẩn **[Conventional Commits](https://www.conventionalcommits.org/)**: ``` ():