|
| 1 | +# Commit Changes |
| 2 | + |
| 3 | +Complete workflow: branch check → pre-commit checks → commit → push → PR |
| 4 | + |
| 5 | +## Usage |
| 6 | + |
| 7 | +``` |
| 8 | +/commit [options] |
| 9 | +``` |
| 10 | + |
| 11 | +**Options:** |
| 12 | +- `--push` or `-p`: Push to remote after commit |
| 13 | +- `--pr`: Create PR after push |
| 14 | +- `--all` or `-a`: Commit all changes at once |
| 15 | +- `<path>`: Commit only specific path (e.g., `lib/`) |
| 16 | + |
| 17 | +## Examples |
| 18 | + |
| 19 | +```bash |
| 20 | +# Full workflow: commit lib changes, push, create PR |
| 21 | +/commit lib/ --pr |
| 22 | + |
| 23 | +# Commit all and create PR |
| 24 | +/commit --all --pr |
| 25 | + |
| 26 | +# Just commit specific path |
| 27 | +/commit android/ |
| 28 | + |
| 29 | +# Push to remote after commit |
| 30 | +/commit --push |
| 31 | +``` |
| 32 | + |
| 33 | +## Complete Workflow |
| 34 | + |
| 35 | +### 1. Check Branch |
| 36 | + |
| 37 | +```bash |
| 38 | +# Check current branch |
| 39 | +git branch --show-current |
| 40 | +``` |
| 41 | + |
| 42 | +**If on `main`** -> Create a feature branch first: |
| 43 | +```bash |
| 44 | +git checkout -b feat/<feature-name> |
| 45 | +``` |
| 46 | + |
| 47 | +**If NOT on `main`** -> Proceed with commits directly. |
| 48 | + |
| 49 | +**Branch naming conventions:** |
| 50 | +- `feat/<feature-name>` - New features |
| 51 | +- `fix/<bug-description>` - Bug fixes |
| 52 | +- `docs/<doc-update>` - Documentation only |
| 53 | +- `chore/<task>` - Maintenance tasks |
| 54 | + |
| 55 | +### 2. Check Current Status |
| 56 | + |
| 57 | +```bash |
| 58 | +git status |
| 59 | +git diff --name-only |
| 60 | +``` |
| 61 | + |
| 62 | +### 3. Run Pre-Commit Checks (CRITICAL) |
| 63 | + |
| 64 | +**Before committing, ALL checks must pass:** |
| 65 | + |
| 66 | +```bash |
| 67 | +# 1. Format check (skip generated types.dart) |
| 68 | +git ls-files '*.dart' | grep -v '^lib/types.dart$' | xargs dart format --page-width 80 --output=none --set-exit-if-changed |
| 69 | + |
| 70 | +# 2. Lint check |
| 71 | +flutter analyze |
| 72 | + |
| 73 | +# 3. Test validation |
| 74 | +flutter test |
| 75 | +``` |
| 76 | + |
| 77 | +**If format check fails:** |
| 78 | +```bash |
| 79 | +# Auto-format and retry |
| 80 | +git ls-files '*.dart' | grep -v '^lib/types.dart$' | xargs dart format --page-width 80 |
| 81 | +``` |
| 82 | + |
| 83 | +**Alternative:** Run `./scripts/pre-commit-checks.sh` for all checks at once. |
| 84 | + |
| 85 | +### 4. Stage Changes |
| 86 | + |
| 87 | +**Specific path:** |
| 88 | +```bash |
| 89 | +git add <path> |
| 90 | +``` |
| 91 | + |
| 92 | +**All changes:** |
| 93 | +```bash |
| 94 | +git add . |
| 95 | +``` |
| 96 | + |
| 97 | +### 5. Review Staged Changes |
| 98 | + |
| 99 | +```bash |
| 100 | +git diff --cached --stat |
| 101 | +git diff --cached --name-only |
| 102 | +``` |
| 103 | + |
| 104 | +### 6. Create Commit |
| 105 | + |
| 106 | +Follow conventional commit format: |
| 107 | + |
| 108 | +```bash |
| 109 | +git commit -m "$(cat <<'EOF' |
| 110 | +<type>: <description> |
| 111 | +
|
| 112 | +<body - what changed and why> |
| 113 | +
|
| 114 | +Co-Authored-By: Claude Opus 4.5 <[email protected]> |
| 115 | +EOF |
| 116 | +)" |
| 117 | +``` |
| 118 | + |
| 119 | +**Commit Types:** |
| 120 | +| Type | Description | |
| 121 | +|------|-------------| |
| 122 | +| `feat` | New feature | |
| 123 | +| `fix` | Bug fix | |
| 124 | +| `docs` | Documentation only | |
| 125 | +| `refactor` | Code refactoring | |
| 126 | +| `chore` | Maintenance tasks | |
| 127 | +| `test` | Adding/updating tests | |
| 128 | + |
| 129 | +### 7. Push to Remote |
| 130 | + |
| 131 | +```bash |
| 132 | +git push -u origin <branch-name> |
| 133 | +``` |
| 134 | + |
| 135 | +### 8. Create Pull Request |
| 136 | + |
| 137 | +```bash |
| 138 | +gh pr create --title "<type>: <description>" --body "$(cat <<'EOF' |
| 139 | +## Summary |
| 140 | +
|
| 141 | +<1-3 bullet points describing changes> |
| 142 | +
|
| 143 | +## Changes |
| 144 | +
|
| 145 | +- Change 1 |
| 146 | +- Change 2 |
| 147 | +
|
| 148 | +## Test plan |
| 149 | +
|
| 150 | +- [ ] `dart format --set-exit-if-changed .` passes |
| 151 | +- [ ] `flutter analyze` passes |
| 152 | +- [ ] `flutter test` passes |
| 153 | +
|
| 154 | +Generated with [Claude Code](https://claude.ai/code) |
| 155 | +EOF |
| 156 | +)" |
| 157 | +``` |
| 158 | + |
| 159 | +--- |
| 160 | + |
| 161 | +## Commit Order (For Cross-Platform Changes) |
| 162 | + |
| 163 | +When making changes across platforms, commit in this order: |
| 164 | + |
| 165 | +| Order | Path | Description | |
| 166 | +|-------|------|-------------| |
| 167 | +| 1 | `lib/` | Dart library code (excluding types.dart) | |
| 168 | +| 2 | `android/` | Android implementation | |
| 169 | +| 3 | `ios/` | iOS implementation | |
| 170 | +| 4 | `example/` | Example app changes | |
| 171 | +| 5 | `test/` | Test updates | |
| 172 | +| 6 | Root files | pubspec.yaml, README.md, etc. | |
| 173 | + |
| 174 | +**IMPORTANT - Never edit `lib/types.dart`:** |
| 175 | +This file is auto-generated. Regenerate via `./scripts/generate-type.sh`. |
| 176 | + |
| 177 | +--- |
| 178 | + |
| 179 | +## Example Commit Messages |
| 180 | + |
| 181 | +**New feature:** |
| 182 | +``` |
| 183 | +feat: add subscription offer support |
| 184 | +
|
| 185 | +- Add SubscriptionOfferIOS for iOS promotional offers |
| 186 | +- Add SubscriptionOfferAndroid for Android offers |
| 187 | +- Update fetchProducts to include offer details |
| 188 | +
|
| 189 | +Co-Authored-By: Claude Opus 4.5 <[email protected]> |
| 190 | +``` |
| 191 | + |
| 192 | +**Bug fix:** |
| 193 | +``` |
| 194 | +fix: resolve purchase validation error on iOS |
| 195 | +
|
| 196 | +- Handle edge case where transaction ID is null |
| 197 | +- Add proper error handling for StoreKit exceptions |
| 198 | +
|
| 199 | +Co-Authored-By: Claude Opus 4.5 <[email protected]> |
| 200 | +``` |
| 201 | + |
| 202 | +**Documentation:** |
| 203 | +``` |
| 204 | +docs: update API documentation for getAvailablePurchases |
| 205 | +
|
| 206 | +- Add PurchaseOptions parameter documentation |
| 207 | +- Include iOS-specific behavior notes |
| 208 | +
|
| 209 | +Co-Authored-By: Claude Opus 4.5 <[email protected]> |
| 210 | +``` |
| 211 | + |
| 212 | +**Chore:** |
| 213 | +``` |
| 214 | +chore: bump version to 8.2.6 |
| 215 | +
|
| 216 | +Co-Authored-By: Claude Opus 4.5 <[email protected]> |
| 217 | +``` |
| 218 | + |
| 219 | +--- |
| 220 | + |
| 221 | +## Example PR Body |
| 222 | + |
| 223 | +```markdown |
| 224 | +## Summary |
| 225 | + |
| 226 | +- Add win-back offer support for iOS 18+ |
| 227 | +- Improve error handling for Android purchase flow |
| 228 | +- Update documentation with new API examples |
| 229 | + |
| 230 | +## Changes |
| 231 | + |
| 232 | +### Dart Library (lib/) |
| 233 | +- Add `WinBackOfferIOS` type |
| 234 | +- Update `requestPurchase` to support offers |
| 235 | + |
| 236 | +### iOS (ios/) |
| 237 | +- Implement StoreKit 2 win-back offer handling |
| 238 | +- Add offer eligibility checking |
| 239 | + |
| 240 | +### Android (android/) |
| 241 | +- Improve BillingClient error mapping |
| 242 | +- Add retry logic for transient failures |
| 243 | + |
| 244 | +## Test plan |
| 245 | + |
| 246 | +- [x] `dart format --set-exit-if-changed .` passes |
| 247 | +- [x] `flutter analyze` passes |
| 248 | +- [x] `flutter test` passes |
| 249 | + |
| 250 | +Generated with [Claude Code](https://claude.ai/code) |
| 251 | +``` |
| 252 | + |
| 253 | +--- |
| 254 | + |
| 255 | +## Quick Reference |
| 256 | + |
| 257 | +```bash |
| 258 | +# Full workflow from main |
| 259 | +git checkout -b feat/my-feature |
| 260 | + |
| 261 | +# Run pre-commit checks |
| 262 | +./scripts/pre-commit-checks.sh |
| 263 | + |
| 264 | +# Stage and commit |
| 265 | +git add lib/ |
| 266 | +git commit -m "feat: add new feature" |
| 267 | + |
| 268 | +git add android/ ios/ |
| 269 | +git commit -m "feat: implement native support" |
| 270 | + |
| 271 | +git add test/ |
| 272 | +git commit -m "test: add unit tests" |
| 273 | + |
| 274 | +# Push and create PR |
| 275 | +git push -u origin feat/my-feature |
| 276 | +gh pr create --title "feat: add new feature" --body "..." |
| 277 | +``` |
0 commit comments