这是indexloc提供的服务,不要输入任何密码
Skip to content

winnerx0/commit-buddy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Commit Buddy

Commit Buddy is an open-source Command Line Interface (CLI) tool written in Go that leverages the Gemini API to automatically generate intelligent Git commit messages based on your staged changes. Say goodbye to generic commit messages and hello to a more descriptive and meaningful commit history!

✨ Features

  • AI-Powered Commit Messages: Generates concise and relevant commit messages by analyzing your git diff --staged output using the Gemini API.

  • Seamless CLI Integration: Integrates directly into your Git workflow, allowing you to generate messages with simple commands.

  • Interactive Commit Prompt: Displays the generated git commit -m "message" command directly in your terminal's input line, allowing you to edit it, press Enter to commit, or Ctrl+C to abort, just like a normal terminal command.

  • Open Source: Built with transparency and community contributions in mind.

🚀 Getting Started

Prerequisites

Before you begin, ensure you have the following installed:

Installation

# bash -c "{curl -s https://github.com/winnerx0/commit-buddy.git 
git clone https://github.com/winnerx0/commit-buddy.git

cd commit-buddy

go build -o cb .

This will create an executable named cb in your current directory.

(Optional) Add to your PATH:

# On Linux/macOS

sudo mv cb /usr/local/bin/

API Key Setup

Commit Buddy requires your Gemini API key to function. It reads this key from an environment variable named GEMINI_API_KEY.

Recommended for current session:

export GEMINI_API_KEY="YOUR_GEMINI_API_KEY_HERE"

For persistent setup:

  • Bash/Zsh: Add the export line to your ~/.bashrc, ~/.zshrc, or ~/.profile file.

  • Windows (Command Prompt):

    setx GEMINI_API_KEY "YOUR_GEMINI_API_KEY_HERE"
    
  • Windows (PowerShell):

    $env:GEMINI_API_KEY="YOUR_GEMINI_API_KEY_HERE"
    
    # To make it persistent, add this to your PowerShell profile script
    

💡 Usage

Navigate to your Git repository, stage your changes, and then run Commit Buddy:

git add .

cb

Commit Buddy will then:

  1. Fetch the staged changes (git diff --staged).

  2. Send the diff to the Gemini API.

  3. Display the AI-generated commit message.

Generated Commit Message Example:


---

feat(user): Add new user authentication module

- Introduce a new authentication modul to handle user login and registration.

---

The git commit command will then appear on your terminal's input line, pre-filled with the generated message. You can now:

  • Press Enter: To execute the command as is.

  • Press Ctrl+C: To abort the commit and exit Commit Buddy.

🤝 Contributing

We welcome contributions to Commit Buddy! If you have ideas for new features, bug fixes, or improvements, please feel free to:

  1. Fork the repository.

  2. Create a new branch:

    git checkout -b feature/your-feature-name
    
  3. Make your changes.

  4. Commit your changes:

    git commit -m 'feat: Add new feature'
    
  5. Push to the branch:

    git push origin feature/your-feature-name
    
  6. Open a Pull Request.

Please ensure your code adheres to Go best practices and includes appropriate tests.

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.Commit Buddy

About

An AI git commit message generator

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published