This document describes how to use fastcommit to generate commit messages for GitHub Pull Requests.
The fastcommit pr command allows you to generate a commit message for an entire Pull Request. This is particularly useful when you're ready to merge a PR and need a comprehensive commit message that summarizes all the changes.
Before using the PR integration, ensure you have:
-
GitHub CLI (
gh) installed# Check if gh is installed gh --version # Install gh on macOS brew install gh # Install gh on Linux # See: https://github.com/cli/cli/blob/trunk/docs/install_linux.md
-
GitHub CLI authenticated
gh auth login
# Auto-detect PR from current branch
fastcommit pr
# Generate commit message for a specific PR
fastcommit pr 123When running fastcommit pr outside the target repository, use the --repo flag:
fastcommit pr 123 --repo owner/repofastcommit pr [PR_NUMBER] [OPTIONS]
Arguments:
[PR_NUMBER] PR number to generate commit message for.
If not specified, auto-detects from current branch.
Options:
--repo <REPO> Specify repository (format: owner/repo)
--conventional <BOOL> Enable conventional commit style (true/false)
-l, --language <LANG> Specify language (en/zh)
-v, --verbosity <LEVEL> Set detail level (verbose/normal/quiet)
-p, --prompt <TEXT> Additional context for AI
--no-sanitize Disable sensitive info sanitizer
--no-wrap Disable text wrapping
--wrap-width <WIDTH> Set custom line width for wrapping
# Assuming you're on a branch with an open PR
fastcommit prOutput:
feat: add user authentication system
- Implement JWT-based authentication
- Add login/logout endpoints
- Integrate with existing user service
- Add rate limiting for auth endpoints
fastcommit pr 456 --conventional trueOutput:
fix(auth): resolve token refresh issue
- Fix improper token validation on refresh
- Add proper error handling for expired tokens
- Update token storage to use secure cookies
fastcommit pr 789 -p "This PR fixes the performance issues reported in issue #123"fastcommit pr 123 -l zhOutput:
feat: 添加用户认证系统
- 实现 JWT 认证机制
- 添加登录/登出接口
- 与现有用户服务集成
- 添加认证接口的速率限制
-
PR Detection: If no PR number is specified,
fastcommitusesgh pr viewto detect the PR associated with the current branch. -
Diff Retrieval: The tool fetches the PR diff using
gh pr diff. -
Message Generation: The diff is processed by the AI to generate a commit message, using the same logic as the standard
fastcommitcommand.
Install GitHub CLI:
- macOS:
brew install gh - Linux: See installation guide
- Windows:
winget install GitHub.cli
This happens when:
- You're not on a branch with an open PR
- The PR is in a different repository
Solution: Specify the PR number explicitly:
fastcommit pr 123This usually indicates:
- You're not authenticated with GitHub CLI
Solution: Run gh auth login
This happens when the PR has no changes (empty PR).
-
Use with PR merge: Generate the commit message before merging:
# Generate the message fastcommit pr 123 # Then merge with the generated message gh pr merge 123 --merge
-
Combine with conventional commits: For projects following conventional commit conventions:
fastcommit pr 123 --conventional true -
Add merge context: Provide additional context about the PR's purpose:
fastcommit pr 123 -p "Closes #456, implements feature requested by users"
- README.md - Main documentation
- GitHub CLI Documentation