|
| 1 | + |
| 2 | +# 🚀 Git Workflow & Best Practices |
| 3 | + |
| 4 | +A concise, opinionated workflow for the **Frontend**, **Controller**, and **Core** teams working on NEBULA Platform. |
| 5 | + |
| 6 | +Following these conventions minimises merge conflicts, preserves history, and accelerates delivery. |
| 7 | + |
| 8 | +--- |
| 9 | + |
| 10 | +## 1. Branch Model |
| 11 | + |
| 12 | +``` |
| 13 | +main ──▶ production (always deployable) |
| 14 | +│ |
| 15 | +├─ develop ──▶ integration branch |
| 16 | +│ ├─ feature/<scope>-<desc> |
| 17 | +│ ├─ bugfix/<scope>-<desc> |
| 18 | +│ ├─ hotfix/<scope>-<desc> |
| 19 | +│ └─ release/<version> |
| 20 | +``` |
| 21 | + |
| 22 | +### 1.1 Branch Types |
| 23 | + |
| 24 | +| Branch | Purpose | |
| 25 | +|---------------|-------------------------------------------------------------------------| |
| 26 | +| `main` | Stable, released code. **Direct commits are blocked.** | |
| 27 | +| `develop` | Integration of completed work before a release. | |
| 28 | +| `feature/*` | New functionality. | |
| 29 | +| `bugfix/*` | Non‑critical fixes. | |
| 30 | +| `hotfix/*` | **Critical** production patches. | |
| 31 | +| `release/*` | Final hardening + version bump before shipping. | |
| 32 | + |
| 33 | +> **Rule of thumb:** _Every change flows through a Pull Request (PR) — never push to `main` or `develop` directly._ |
| 34 | +
|
| 35 | +--- |
| 36 | + |
| 37 | +## 2. Naming Conventions |
| 38 | + |
| 39 | +| Type | Pattern | Example | |
| 40 | +|-----------|-------------------------------------------|-------------------------------------| |
| 41 | +| Feature | `feature/<component>-<desc>` | `feature/frontend-login-page` | |
| 42 | +| Bugfix | `bugfix/<component>-<desc>` | `bugfix/controller-null-pointer` | |
| 43 | +| Hotfix | `hotfix/<component>-<desc>` | `hotfix/core-memory-leak` | |
| 44 | +| Release | `release/<major>.<minor>.<patch>` | `release/1.4.0` | |
| 45 | + |
| 46 | +--- |
| 47 | + |
| 48 | +## 3. Conventional Commits |
| 49 | + |
| 50 | +Format: `<type>(<scope>): <short summary>` |
| 51 | + |
| 52 | +| Type | Use for … | Example | |
| 53 | +|-------------|-------------------------------------|---------------------------------------------------| |
| 54 | +| `feat` | New feature | `feat(controller): add /scenarios endpoint` | |
| 55 | +| `fix` | Bug fix | `fix(frontend): correct form validation` | |
| 56 | +| `docs` | Docs only | `docs(core): explain rule engine config` | |
| 57 | +| `refactor` | Internal restructuring | `refactor(core): extract auth helpers` | |
| 58 | +| `test` | Add/modify tests | `test(frontend): snapshot for Button` | |
| 59 | +| `chore` | Build, tooling, release, cleaning | `chore: removing logs` | |
| 60 | + |
| 61 | +_References to issues_: add `Closes #123` in the commit body. |
| 62 | + |
| 63 | +--- |
| 64 | + |
| 65 | +## 4. End‑to‑End Workflow |
| 66 | + |
| 67 | +1. **Create an issue** describing scope, acceptance criteria, and dependencies. |
| 68 | +2. **Branch from `develop`** following the naming rules. |
| 69 | +3. **Commit early & often** using Conventional Commits. |
| 70 | +4. **Push & open a PR** to `develop`. |
| 71 | + - Assign at least **one reviewer**. |
| 72 | + - CI must pass (lint, tests, build). |
| 73 | +5. **Review & merge** when approved. Delete the remote branch. |
| 74 | + |
| 75 | +### 4.1 Releasing |
| 76 | + |
| 77 | +For planned releases, follow this workflow to ensure stability: |
| 78 | + |
| 79 | +- **When to release**: Based on sprint cycles or feature readiness |
| 80 | +- **Key points**: |
| 81 | + - Release branches isolate stabilization work |
| 82 | + - All changes must be regression tested |
| 83 | + - Coordinates deployment across components |
| 84 | + |
| 85 | + |
| 86 | +1. Branch `release/x.y.z` from `develop`. |
| 87 | +2. Bump version, update CHANGELOG, run full regression tests. |
| 88 | +3. Open PR `release/x.y.z` → `main`; merge when green. |
| 89 | +4. Tag `vX.Y.Z` on `main` (`git tag v1.2.0 && git push origin v1.2.0`). |
| 90 | +5. Merge `main` back into `develop` to keep history linear. |
| 91 | + |
| 92 | +### 4.2 Hotfixing |
| 93 | + |
| 94 | +For critical production issues that need immediate fixes: |
| 95 | + |
| 96 | +- **When to use**: Only for urgent production bugs that can't wait for the next release |
| 97 | +- **Key points**: |
| 98 | + - Hotfixes bypass `develop` and go directly to `main` |
| 99 | + - Must be thoroughly tested despite urgency |
| 100 | + - Requires careful coordination with the team |
| 101 | + - Should be small, focused changes targeting only the critical issue |
| 102 | + |
| 103 | + |
| 104 | +1. Branch `hotfix/...` from `main`. |
| 105 | +2. Fix, test, and open PR **to `main`**. |
| 106 | +3. Tag `vX.Y.Z-hotfix` (or patch bump) after merge. |
| 107 | +4. **Back‑merge** `main` into `develop`. |
| 108 | + |
| 109 | +--- |
| 110 | + |
| 111 | +## 5. Code Review Checklist |
| 112 | + |
| 113 | +> Use this quick checklist before approving a PR. |
| 114 | +
|
| 115 | +- [ ] Code builds & CI is green. |
| 116 | +- [ ] No obvious security, performance, or accessibility issues. |
| 117 | +- [ ] Docs, API spec, and configs updated. |
| 118 | +- [ ] Commit history is clean (squash/rebase as needed). |
| 119 | + |
| 120 | +--- |
| 121 | + |
| 122 | +## 6. House‑Keeping Commands |
| 123 | + |
| 124 | +| Task | Command | |
| 125 | +|----------------------|-------------------------------------------------| |
| 126 | +| Delete local branch | `git branch -d <branch>` | |
| 127 | +| Delete remote branch | `git push origin --delete <branch>` | |
| 128 | +| Sync `develop` | `git pull --rebase origin develop` | |
| 129 | +| Inspect history | `git log --oneline --graph --decorate --all` | |
| 130 | + |
| 131 | +--- |
| 132 | + |
| 133 | +## 7. Additional Tips |
| 134 | + |
| 135 | +- Keep PRs **small** (< 1000 LOC) to speed up review. |
| 136 | +- Use **Draft PRs** to gather feedback early. |
| 137 | + |
| 138 | +--- |
| 139 | + |
| 140 | +## 8. Resources |
| 141 | + |
| 142 | +- [Conventional Commits](https://www.conventionalcommits.org) |
| 143 | +- [Git Branching Model](https://nvie.com/posts/a-successful-git-branching-model/) |
0 commit comments