|
| 1 | +--- |
| 2 | +description: Git Commit Workflow |
| 3 | +--- |
| 4 | + |
| 5 | +## Git Conventional Commit Workflow |
| 6 | + |
| 7 | +Cascade **MUST** follow this workflow to ensure all git changes are reviewed, structured, and committed correctly using the Conventional Commits specification. |
| 8 | + |
| 9 | +### Step 1: Assess the State of the Repository |
| 10 | + |
| 11 | +1. **Check for Uncommitted Changes**: Run `git status` to get an overview of modified, staged, and untracked files. |
| 12 | + |
| 13 | +### Step 2: Stage and Review Changes |
| 14 | + |
| 15 | +1. **Stage All Changes**: Run `git add .` to stage all modifications. |
| 16 | +2. **Collect Staged Changes**: Run `git diff --staged --word-diff` to get a complete overview of all the changes that will be included in the commit. This is crucial for accurately summarizing the changes. |
| 17 | + |
| 18 | +### Step 3: Propose the Commit Message |
| 19 | + |
| 20 | +- Based on the collected diff, formulate a commit message. The message **MUST** be presented to the USER in a markdown block for review before committing. |
| 21 | +- When referencing file changes in a commit body, **MUST** use the filename only (e.g., `McpUtils.cs`), not the full path (e.g. `cci:7://file:///c:/mcp-unity/Editor/Utils/conventional-commits.md:0:0-0:0`). |
| 22 | + |
| 23 | +#### Structuring the Commit |
| 24 | + |
| 25 | +**For commits containing a single, focused change:** |
| 26 | +- Use a standard, single-line header. |
| 27 | +- The body is optional and should only be used for significant explanations. |
| 28 | + |
| 29 | +**For commits containing multiple, logically distinct changes:** |
| 30 | +- The header **MUST** list each distinct change on a separate line. Each line must follow the `<type>(scope): <description>` format. |
| 31 | +- The body should provide a high-level summary of the overall changes. |
| 32 | + |
| 33 | +**Format:** |
| 34 | +# For a single change: |
| 35 | +``` |
| 36 | +<type>(scope): <description> |
| 37 | +
|
| 38 | +[optional footer(s)] |
| 39 | +``` |
| 40 | + |
| 41 | +# For multiple changes: |
| 42 | +``` |
| 43 | +<type>(scope1): <description1> |
| 44 | +<type>(scope2): <description2> |
| 45 | +
|
| 46 | +<body summarizing the overall changes> |
| 47 | +
|
| 48 | +[optional footer(s)] |
| 49 | +``` |
| 50 | + |
| 51 | +- **Types**: `feat`, `fix`, `build`, `chore`, `ci`, `docs`, `perf`, `refactor`, `revert`, `style`, `test`. |
| 52 | +- **Scope**: For providing context (e.g., `feat(api): ...`). |
| 53 | +- **Description**: A concise, imperative summary of a single, distinct change. |
| 54 | +- **Body**: Explain the 'what' and 'impact' of the changes. For commits with multiple headers, the body should summarize the combined effort. |
| 55 | +- **Footer** (Optional): Use for `BREAKING CHANGE:` notifications or for referencing issue numbers (e.g., `Closes #55`). |
| 56 | + |
| 57 | +### Example Commit Message Proposals |
| 58 | + |
| 59 | +Here is how you should present commit messages for review. |
| 60 | + |
| 61 | +#### Example 1: Single Change (No Body Needed) |
| 62 | +For simple, self-explanatory changes where the header is sufficient. |
| 63 | + |
| 64 | +```markdown |
| 65 | +fix(login): Correct typo in user login prompt |
| 66 | + |
| 67 | +Closes #100 |
| 68 | +``` |
| 69 | + |
| 70 | +#### Example 2: Single Change (Body Included) |
| 71 | +For a significant change that requires more context to explain the 'what' and 'why'. |
| 72 | + |
| 73 | +```markdown |
| 74 | +refactor(auth): Overhaul authentication flow to use JWTs |
| 75 | + |
| 76 | +This commit replaces session-based authentication with JWTs to improve statelessness and scalability. |
| 77 | + |
| 78 | +Impacts: |
| 79 | +- API endpoints now expect a JWT in the Authorization header. |
| 80 | +- User login returns a JWT. |
| 81 | +- Session management code has been removed. |
| 82 | + |
| 83 | +Closes #111 |
| 84 | +``` |
| 85 | + |
| 86 | +#### Example 3: Multiple Changes |
| 87 | +For commits that bundle several distinct changes, use a multi-line header and a summary body. |
| 88 | + |
| 89 | +```markdown |
| 90 | +feat(auth): Add password reset functionality |
| 91 | +refactor(login): Revamp login page style |
| 92 | + |
| 93 | +This commit introduces a new login flow and modernizes the UI. It adds a password reset endpoint and decouples the email service for better maintainability. |
| 94 | + |
| 95 | +Impacts: |
| 96 | +- A new API endpoint `/api/auth/reset-password` is now available. |
| 97 | +- The email template system is now in a separate service module. |
| 98 | +- The login page CSS in `login.css` has been updated. |
| 99 | + |
| 100 | +Closes #123 |
| 101 | +``` |
0 commit comments