1.7 KiB
1.7 KiB
description
| description |
|---|
| Generate a commit message based on current changes |
Commit Command
You need to help the user generate a high-quality commit message. Please follow these steps:
1. Fetch Git Information
Run the following commands in parallel to get the current repository state:
git diff- View unstaged changesgit diff --staged- View staged changesgit status- View current branch and file statusgit log --oneline -10- View the last 10 commits to understand the commit message format style
2. Analyze Changes
Based on the fetched information, analyze:
- Current branch name
- File types and scope of changes
- Nature of changes (new feature, fix, refactor, docs, etc.)
- Commit message format style in history (whether using emoji, English/Chinese, following conventional commits, etc.)
3. Generate Commit Message
Based on the above analysis, generate a commit message that meets the following requirements:
- Follow project style: Based on the historical commit format seen in git log
- Accurately describe changes: Clearly explain what was changed
- Be concise: Keep the first line within 50-72 characters (if in English)
- Use correct type: Such as feat, fix, docs, refactor, test, chore, etc. (if the project uses conventional commits)
4. Output Format
After generating the commit message, display it directly to the user and ask if they want to:
- Use this message to commit
- Need to modify it
- Regenerate
Important Notes:
- If there are no changes (git status shows clean), inform the user there are no changes to commit
- If there are only unstaged changes, ask the user if they need to add files first
- The message should describe "why" rather than just "what"