gcommit-jira
v1.1.0
Published
A lightweight CLI tool for generating standardized Git commit messages with JIRA integration
Maintainers
Readme
Git Commit CLI
A lightweight CLI tool for generating standardized Git commit messages with JIRA ticket integration. This tool helps teams maintain consistent commit message formats while seamlessly integrating with JIRA tracking.
Features
- Interactive Prompts: User-friendly prompts guide you through creating standardized commits
- Auto-detect Username: Automatically pulls username from git config
- JIRA Integration: Built-in validation for JIRA ticket format
- Preview Before Commit: Review formatted message before committing
- Lightweight: Minimal dependencies, fast execution
- Cross-platform: Works on Windows, macOS, and Linux
- No Config Files: Uses git configuration only
Commit Message Format
[type]: [username] [JIRATICKET] message
Optional longer descriptionExample Output
[feat]: [John Doe] [JIRA-1234] Add user authentication system
Implemented JWT-based authentication with password hashing
and secure session management.Supported Commit Types
| Type | Description |
|------|-------------|
| feat | A new feature |
| fix | A bug fix |
| build | Changes to build system or dependencies |
| ci | Changes to CI configuration |
| docs | Documentation only changes |
| refactor | Code change that neither fixes a bug nor adds a feature |
| test | Adding or updating tests |
| chore | Other changes that don't modify src or test files |
JIRA Ticket Format
JIRA tickets must follow the pattern: PROJECT-NUMBER
Valid Examples:
JIRA-1111PROJ-123ABC-4567
Invalid Examples:
jira-123(lowercase not allowed)JIRA123(missing hyphen)JIRA-(missing number)
Installation
Global Installation (Recommended)
# Clone or download the repository
cd git-commit-cli
# Install dependencies
npm install
# Install globally
npm install -g .
# Or use npm link for development
npm linkLocal Installation
# Install dependencies
npm install
# Run directly
npm startUsage
Basic Usage
Once installed globally, simply run:
gcommitThe tool will guide you through an interactive session:
- Select commit type - Choose from the list of supported types
- Enter JIRA ticket - Provide your JIRA ticket number (e.g., JIRA-1234)
- Enter commit message - Short description of your changes
- Enter description (optional) - Longer, detailed description
- Review - Preview the formatted message
- Confirm - Proceed with commit or cancel
Prerequisites
Before running gcommit, make sure to:
Stage your changes:
git add <files>Ensure git is configured:
git config user.name "Your Name" git config user.email "[email protected]"If not configured, the tool will prompt you for a username.
Example Workflow
# 1. Make changes to your code
vim src/app.js
# 2. Stage your changes
git add src/app.js
# 3. Run the commit tool
gcommit
# 4. Follow the interactive prompts
? Select the type of change you're committing: feat - A new feature
? Enter JIRA ticket number (e.g., JIRA-1111): JIRA-1234
? Enter commit message (short description): Add user authentication
? Enter longer description (optional, press Enter to skip): Implemented JWT-based auth system
# 5. Review the formatted message
═══════════════════════════════════════════════════════════
📝 COMMIT MESSAGE PREVIEW
═══════════════════════════════════════════════════════════
[feat]: [John Doe] [JIRA-1234] Add user authentication
Implemented JWT-based auth system
═══════════════════════════════════════════════════════════
# 6. Confirm
? Do you want to proceed with this commit? (Y/n) Y
✓ Commit created successfully!Help Command
View help information:
gcommit --helpOutput:
Usage: gcommit [options]
Generate standardized Git commit messages with JIRA ticket integration
Options:
-V, --version output the version number
-h, --help display help for command
Example usage:
$ gcommit
This will start an interactive session to create a commit message in the format:
[type]: [username] [JIRATICKET] message
Supported commit types:
feat, fix, build, ci, docs, refactor, test, chore
JIRA ticket format:
Must follow the pattern: PROJECT-1234 (e.g., JIRA-1111, PROJ-123)
Note: Make sure to stage your changes with 'git add' before running this command.Error Handling
The tool provides clear error messages for common issues:
Not a Git Repository
✗ Error: Not a git repository. Please run this command in a git repository.No Staged Changes
✗ Failed to create commit: Command failed...
Make sure you have staged changes using: git add <files>Invalid JIRA Ticket
✗ JIRA ticket must follow the format: PROJECT-1234 (e.g., JIRA-1111)Missing Git Username
⚠️ Git username not found in config.
? Please enter your username:Development
Project Structure
git-commit-cli/
├── bin/
│ └── gcommit.js # Main CLI executable
├── package.json # Project configuration
└── README.md # DocumentationDependencies
- commander (^11.1.0) - CLI framework for building command-line tools
- inquirer (^8.2.6) - Interactive command-line prompts
- chalk (^4.1.2) - Terminal string styling for colored output
Testing Locally
# Install dependencies
npm install
# Link for local testing
npm link
# Test the command
gcommit
# Unlink when done
npm unlinkComparison with Commitizen
While inspired by Commitizen, this tool is:
- More Lightweight: Fewer dependencies, faster startup
- JIRA-Focused: Built-in JIRA ticket validation
- Custom Format: Specific format:
[type]: [username] [JIRATICKET] message - No Config Files: Uses git config only, no additional configuration
- Simplified: Focused on one specific workflow
Troubleshooting
Issue: Command not found after global install
Solution:
# Ensure npm global bin is in your PATH
npm config get prefix
# Add to PATH (example for Unix-based systems)
export PATH=$PATH:$(npm config get prefix)/binIssue: Permission denied
Solution:
# Make the file executable
chmod +x bin/gcommit.js
# Or reinstall globally with proper permissions
sudo npm install -g .Issue: Inquirer prompts not working
Solution:
- Ensure you're running in a proper terminal (not a non-interactive shell)
- Update Node.js to version 14 or higher
License
MIT
Contributing
Contributions are welcome! Please feel free to submit issues or pull requests.
Support
For issues, questions, or suggestions, please open an issue in the repository.
Made with ❤️ for developers who care about consistent commit messages
