docs: 重构命令和技能文档体系,规范化文档格式和内容组织
This commit is contained in:
@@ -2,188 +2,51 @@
|
||||
description: Commit staged files with auto-generated message and create version tag
|
||||
---
|
||||
|
||||
# git-commit
|
||||
Auto-generate a commit message for staged files, commit to the local repository, and create a version tag following semantic versioning.
|
||||
|
||||
Auto-generate commit message for staged files, commit to local repository, and create version tag.
|
||||
Please follow the git workflow defined in `@skill/git/SKILL.md`:
|
||||
|
||||
## What It Does
|
||||
1. **Check staging area** - Verify files are staged with `git diff --cached --name-only`
|
||||
- If empty, inform the user and stop
|
||||
2. **Collect information** - Run these commands in parallel:
|
||||
- `git status`
|
||||
- `git diff --cached`
|
||||
- `git log --oneline -10`
|
||||
- `git tag --list | sort -V | tail -5`
|
||||
- Read `@AGENTS.md` if it exists (repository type, version rules, project structure)
|
||||
3. **Detect repository type** - Polyrepo (tag: `1.2.0`) or Monorepo (tag: `subproject-1.2.0`)
|
||||
4. **Detect project type and version** - Check for version files:
|
||||
- iOS: `*.xcodeproj/project.pbxproj` → `MARKETING_VERSION`
|
||||
- Node.js: `package.json` → `version`
|
||||
- Android: `build.gradle(.kts)` → `versionName`
|
||||
- Go: Git tag only
|
||||
5. **Generate commit message** following Conventional Commits:
|
||||
- Format: `<type>(<scope>): <subject>`
|
||||
- Use Chinese for commit messages (macOS/Linux)
|
||||
- Types: feat, fix, docs, style, refactor, perf, test, chore, ci, build
|
||||
- For monorepo, use subproject as scope if changes affect single subproject
|
||||
6. **Update version number** if needed:
|
||||
- feat: minor +1 (1.2.0 → 1.3.0)
|
||||
- fix/perf: patch +1 (1.2.3 → 1.2.4)
|
||||
- Breaking change: major +1 (1.2.3 → 2.0.0)
|
||||
- Only for user-perceivable changes (feat, fix, perf, breaking)
|
||||
- Add updated version file to staging
|
||||
7. **Commit changes** with generated message
|
||||
8. **Create version tag** if version was updated (unless user specified "skip tag"):
|
||||
- Polyrepo: `git tag -a "1.2.0" -m "commit message"`
|
||||
- Monorepo: `git tag -a "subproject-1.2.0" -m "commit message"`
|
||||
|
||||
- Analyzes staged changes
|
||||
- Auto-generates meaningful commit message following Conventional Commits
|
||||
- Detects project type and updates version number if needed
|
||||
- Creates appropriate git tag (polyrepo or monorepo format)
|
||||
- Does NOT push to remote (local only)
|
||||
**Options:**
|
||||
- User can input "skip tag" or "skip" to skip tag creation
|
||||
|
||||
## Quick Start
|
||||
|
||||
Use this command when you have files in staging area and want to commit with proper version tagging.
|
||||
|
||||
## Workflow
|
||||
|
||||
This command follows the git workflow defined in `skill/git/SKILL.md`:
|
||||
|
||||
1. ✓ Check staging area (must have files)
|
||||
2. ✓ Analyze changes and repository type
|
||||
3. ✓ Detect project type and version file
|
||||
4. ✓ Generate commit message (Conventional Commits)
|
||||
5. ✓ Update version number if needed
|
||||
6. ✓ Commit with generated message
|
||||
7. ✓ Create version tag
|
||||
8. ✗ Skip push (use `/git-push` to push)
|
||||
|
||||
## Prerequisites
|
||||
|
||||
**Staging area must not be empty:**
|
||||
```bash
|
||||
git add <files>
|
||||
```
|
||||
|
||||
## Options
|
||||
|
||||
User can optionally input:
|
||||
- **"skip tag"** or **"skip"**: Skip tag creation, only commit
|
||||
|
||||
## Steps
|
||||
|
||||
### 1. Check Staging Area
|
||||
|
||||
```bash
|
||||
git diff --cached --name-only
|
||||
```
|
||||
|
||||
**If empty:**
|
||||
- Display: "暂存区为空,请先使用 `git add` 添加文件。"
|
||||
- **Terminate execution**
|
||||
|
||||
### 2. Collect Information (parallel)
|
||||
|
||||
```bash
|
||||
git status
|
||||
git diff --cached
|
||||
git log --oneline -10
|
||||
git tag --list | sort -V | tail -5
|
||||
```
|
||||
|
||||
If `AGENTS.md` exists, read it for:
|
||||
- Repository type (polyrepo/monorepo)
|
||||
- Version update rules
|
||||
- Project structure
|
||||
|
||||
### 3. Detect Repository Type
|
||||
|
||||
- **Polyrepo**: Single project, tag format `1.2.0`
|
||||
- **Monorepo**: Multiple subprojects, tag format `<subproject>-1.2.0`
|
||||
|
||||
Detection:
|
||||
- Check `AGENTS.md` for monorepo indicator
|
||||
- Check directory structure (`packages/`, `apps/`, etc.)
|
||||
- Analyze changed file paths for subproject scope
|
||||
|
||||
### 4. Detect Project Type and Version
|
||||
|
||||
Follow `skill/git/SKILL.md` guidelines:
|
||||
|
||||
**Common project types:**
|
||||
- iOS: `*.xcodeproj/project.pbxproj` → `MARKETING_VERSION`
|
||||
- Node.js: `package.json` → `version`
|
||||
- Android: `build.gradle(.kts)` → `versionName`
|
||||
- Go: Git tag only (no version file)
|
||||
- etc.
|
||||
|
||||
**Version increment rules:**
|
||||
- `feat`: minor +1 → `1.2.0` → `1.3.0`
|
||||
- `fix`: patch +1 → `1.2.3` → `1.2.4`
|
||||
- `perf`: patch +1
|
||||
- Breaking change: major +1 → `1.2.3` → `2.0.0`
|
||||
|
||||
**Only update version for user-perceivable changes:**
|
||||
- ✓ feat, fix, perf, breaking changes
|
||||
- ✗ docs, test, refactor, style, chore, ci, build
|
||||
|
||||
### 5. Generate Commit Message
|
||||
|
||||
Follow Conventional Commits specification:
|
||||
|
||||
**Format:**
|
||||
```
|
||||
<type>(<scope>): <subject>
|
||||
|
||||
<body>
|
||||
```
|
||||
|
||||
**Commit language:**
|
||||
- macOS/Linux: Chinese (中文)
|
||||
- Windows: English (encoding issue)
|
||||
|
||||
**Monorepo scope:**
|
||||
- If changes affect single subproject: `feat(ios): 添加新功能`
|
||||
- If multiple subprojects: `feat: 添加新功能`
|
||||
|
||||
### 6. Update Version Number
|
||||
|
||||
If version update is needed:
|
||||
|
||||
1. Update version file with new version
|
||||
2. Add version file to staging: `git add <version-file>`
|
||||
3. Verify: `git diff --cached --name-only`
|
||||
|
||||
### 7. Commit Changes
|
||||
|
||||
```bash
|
||||
# macOS/Linux (Chinese)
|
||||
git commit -m "feat(android): 添加用户认证"
|
||||
|
||||
# Windows (English)
|
||||
git commit -m "feat(android): add user authentication"
|
||||
|
||||
# Multi-line (macOS/Linux)
|
||||
git commit -m "$(cat <<'EOF'
|
||||
feat: add user authentication
|
||||
|
||||
- Add OAuth2 support
|
||||
- Implement JWT tokens
|
||||
EOF
|
||||
)"
|
||||
```
|
||||
|
||||
### 8. Create Tag
|
||||
|
||||
**Only if:**
|
||||
- Version update occurred
|
||||
- User didn't input "skip tag"
|
||||
|
||||
**Tag format:**
|
||||
- Polyrepo: `git tag -a "1.2.0" -m "feat: add feature"`
|
||||
- Monorepo: `git tag -a "ios-1.2.0" -m "feat(ios): add feature"`
|
||||
|
||||
**Tag annotation:**
|
||||
- Use same content as commit message
|
||||
- Multi-line commits → multi-line annotations
|
||||
|
||||
### 9. Display Result
|
||||
|
||||
Show summary in Chinese:
|
||||
**Display result in Chinese:**
|
||||
```
|
||||
✓ 提交成功
|
||||
|
||||
提交信息:feat(android): 添加用户认证
|
||||
版本标签:android-1.3.0
|
||||
提交信息:[commit message]
|
||||
版本标签:[tag] (如果创建了)
|
||||
|
||||
要推送到远程仓库,请运行:/git-push
|
||||
```
|
||||
|
||||
## Use Cases
|
||||
|
||||
- Commit staged changes with proper versioning
|
||||
- Create local version tag for release preparation
|
||||
- Follow semantic versioning automatically
|
||||
|
||||
## Related Commands
|
||||
|
||||
- `/git-status` - Check file changes before commit
|
||||
- `/git-push` - Push commits and tags to remote
|
||||
- `/git-push-tags` - Push tags only
|
||||
|
||||
## Reference
|
||||
|
||||
Complete workflow documentation: `skill/git/SKILL.md`
|
||||
**Important:** This command does NOT push to remote. Use `/git-push` to push commits and tags.
|
||||
|
||||
Reference in New Issue
Block a user