File size: 9,463 Bytes
1e2511f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 | # Commit Guidelines
## Professional Commit Message Standards
This document outlines the commit message standards for the Chahuadev Fix Comments Tool project. Following these guidelines ensures clear project history and facilitates automated tooling.
## Commit Message Format
```
<type>(<scope>): <subject>
<body>
<footer>
```
### Type
Must be one of the following:
| Type | Description | Example |
|------|-------------|---------|
| `feat` | New feature | `feat(generator): add bilingual comment support` |
| `fix` | Bug fix | `fix(parser): handle async function comments` |
| `docs` | Documentation only | `docs(api): update comment template examples` |
| `style` | Code style changes | `style(format): fix indentation consistency` |
| `refactor` | Code refactoring | `refactor(analyzer): improve function detection` |
| `perf` | Performance improvement | `perf(ast): optimize parsing performance` |
| `test` | Adding/updating tests | `test(bilingual): add translation tests` |
| `chore` | Maintenance tasks | `chore(deps): update babel dependencies` |
| `ci` | CI/CD changes | `ci(actions): add comment quality checks` |
| `build` | Build system changes | `build(webpack): optimize bundle size` |
| `revert` | Revert previous commit | `revert: remove experimental feature` |
### Scope
The scope should indicate the part of the codebase affected:
| Scope | Description |
|-------|-------------|
| `cli` | Command line interface |
| `parser` | AST parsing and analysis |
| `generator` | Comment generation engine |
| `analyzer` | Function and code analysis |
| `bilingual` | Bilingual comment features |
| `ai` | AI-friendly formatting |
| `templates` | Comment templates |
| `config` | Configuration management |
| `docs` | Documentation |
| `tests` | Test files |
| `build` | Build configuration |
### Subject
- Use imperative mood: "add" not "added" or "adds"
- Don't capitalize first letter
- No period at the end
- Maximum 50 characters
### Body
- Wrap at 72 characters
- Explain the what and why, not how
- Use imperative mood
- Separate from subject with blank line
### Footer
- Reference issues and breaking changes
- Format: `Closes #123` or `Fixes #456`
- Breaking changes: `BREAKING CHANGE: description`
## Examples
### Feature Addition
```
feat(bilingual): add Thai language support for comments
Add comprehensive Thai language support for bilingual comment
generation. Includes translation templates for common programming
patterns and automatic language detection.
Features include:
- Thai translation templates for functions and methods
- Automatic language detection based on existing comments
- Bilingual JSDoc format with English/Thai descriptions
- Configuration options for language preferences
This enables Thai developers to maintain code documentation
in both languages, improving code accessibility and team
collaboration.
Closes #67
```
### Bug Fix
```
fix(parser): correctly handle TypeScript generic functions
Fix AST parsing issue where TypeScript generic function signatures
were not properly analyzed, causing missing type information in
generated comments.
The fix includes:
- Improved generic parameter detection
- Proper constraint parsing for bounded generics
- Type inference for complex generic expressions
Before: Generic functions were parsed as regular functions
After: Full generic signature analysis with type constraints
Fixes #89
```
### Breaking Change
```
feat(generator): update comment template format
Change default comment template format to improve readability
and maintain consistency with modern JSDoc standards.
New features:
- Standardized parameter descriptions
- Improved return value documentation
- Better example code formatting
- Enhanced type information display
BREAKING CHANGE: Default comment template format changed from
custom format to standard JSDoc. Users with custom templates
may need to update their configuration.
Migration guide available in MIGRATION.md
Closes #45
```
### Documentation Update
```
docs(templates): add bilingual comment examples
Add comprehensive examples for bilingual comment generation
including various function patterns and use cases.
Examples include:
- Simple function documentation
- Complex generic functions
- React component documentation
- Node.js API documentation
- Error handling patterns
Improves developer onboarding and reduces configuration time.
```
### Performance Improvement
```
perf(ast): optimize function analysis performance
Implement caching strategy for AST analysis, reducing processing
time by 60% for large codebases with many functions.
Optimizations include:
- Function signature caching based on content hash
- Incremental analysis for modified files only
- Memory-efficient AST node storage
- Parallel processing for independent functions
Benchmark results show 60% improvement in processing time
for projects with 1000+ functions.
Closes #112
```
### Test Addition
```
test(bilingual): add comprehensive translation tests
Add test suite covering Thai-English bilingual comment generation
across various function types and complexity levels.
Test coverage includes:
- Simple function translations
- Complex generic function translations
- React component comment translations
- Error handling and edge cases
- Template customization scenarios
Increases bilingual feature test coverage to 95%.
```
## Commit Message Best Practices
### Do's
- Keep commits atomic (one logical change per commit)
- Write clear, descriptive subject lines
- Explain the reasoning behind changes in the body
- Reference relevant issues and pull requests
- Use consistent formatting and terminology
- Write commit messages for future maintainers
### Don'ts
- Don't write vague messages like "fix stuff" or "update code"
- Don't include file names in the subject (use scope instead)
- Don't exceed character limits (50 for subject, 72 for body)
- Don't commit unrelated changes together
- Don't use past tense ("fixed" instead of "fix")
- Don't commit commented-out code or debug logs
## Git Workflow Integration
### Commit Hooks
We recommend setting up commit hooks to enforce these standards:
```bash
# Install commitizen for guided commit messages
npm install -g commitizen cz-conventional-changelog
# Set up the adapter
echo '{ "path": "cz-conventional-changelog" }' > ~/.czrc
```
### Usage with Commitizen
```bash
# Use commitizen for guided commits
git cz
```
### Automated Validation
Our CI pipeline includes commit message validation:
```yaml
# .github/workflows/validate-commits.yml
- name: Validate Commit Messages
uses: wagoid/commitlint-github-action@v4
```
## Release Notes Generation
Following these guidelines enables automated release notes:
```bash
# Generate changelog from commits
conventional-changelog -p angular -i CHANGELOG.md -s
```
## Semantic Versioning Impact
Commit types automatically determine version bumps:
| Commit Type | Version Bump | Example |
|-------------|--------------|---------|
| `fix` | PATCH (3.0.1-beta) | Bug fixes |
| `feat` | MINOR (3.1.0-beta) | New features |
| `BREAKING CHANGE` | MAJOR (4.0.0-beta) | Breaking changes |
## Examples by Project Area
### Parser-Related Commits
```
fix(parser): handle arrow functions in class methods
feat(parser): add support for TypeScript decorators
perf(parser): optimize AST traversal performance
```
### Comment Generation Commits
```
feat(generator): add AI-friendly comment format
fix(generator): improve parameter description inference
docs(generator): update template customization guide
```
### Bilingual Feature Commits
```
feat(bilingual): add automatic language detection
fix(bilingual): handle mixed-language existing comments
test(bilingual): add translation accuracy tests
```
## Tooling Support
### IDE Integration
Many IDEs support commit message templates:
```bash
# Set Git commit template
git config commit.template ~/.gitmessage
```
### VS Code Extensions
Recommended extensions:
- Conventional Commits
- GitLens
- Git Graph
### Command Line Tools
```bash
# Install helpful CLI tools
npm install -g @commitlint/cli @commitlint/config-conventional
```
## Review Process
During code review, commit messages are evaluated for:
1. **Clarity**: Is the change purpose clear?
2. **Completeness**: Does it explain what and why?
3. **Standards Compliance**: Does it follow our format?
4. **Technical Accuracy**: Does it accurately describe the change?
## Training and Resources
### Internal Resources
- [Commit Message Workshop Recording](internal-link)
- [Interactive Commit Message Tool](internal-link)
- [Project Style Guide](internal-link)
### External Resources
- [Conventional Commits](https://www.conventionalcommits.org/)
- [Git Commit Best Practices](https://chris.beams.io/posts/git-commit/)
- [Angular Commit Guidelines](https://github.com/angular/angular/blob/master/CONTRIBUTING.md#commit)
---
Following these guidelines helps maintain a professional, clear, and useful project history. For questions about commit message standards, please contact the development team at chahuadev@gmail.com. |