Skip to content

Aqua-123/GitR

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GitR - Git commit messages using LLMs

GitR (pronounced as Gitter) is a command-line tool that uses AI to generate conventional commit messages based on your staged changes. It integrates seamlessly with your Git workflow and provides an interactive interface for reviewing and editing generated messages.

(All commit messages to this project are generated by GitR)

Features

  • AI-Powered: Uses OpenAI-compatible APIs to generate intelligent commit messages
  • Conventional Commits: Follows conventional commit message standards
  • Fast Workflow: Quick commit generation with optional confirmation
  • Configurable: Customizable settings for different models and preferences
  • Smart Parsing: Automatically extracts clean commit messages from AI responses
  • Safe: Always shows generated messages before committing
  • Flexible: Multiple usage modes for different workflows

Installation

Prerequisites

  • Go 1.21 or later
  • Git repository
  • OpenAI API key (or compatible API like Shivaay)

Quick Installation

Option 1: Automated Installation Script

Linux/macOS:

git clone <repository-url>
cd gitr
chmod +x install.sh
./install.sh

Windows (PowerShell as Administrator):

git clone <repository-url>
cd gitr
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
.\install.ps1

Option 2: Using Make

Linux/macOS:

git clone <repository-url>
cd gitr
make install

For current user only (no sudo required):

make install-user

Option 3: Manual Installation

git clone <repository-url>
cd gitr
go build -o gitr .

# Install system-wide (requires sudo on Unix)
sudo cp gitr /usr/local/bin/
sudo chmod +x /usr/local/bin/gitr

# Or install for current user
mkdir -p ~/bin
cp gitr ~/bin/
chmod +x ~/bin/gitr
# Make sure ~/bin is in your PATH

Verify Installation

After installation, verify GitR is working:

gitr --help

You should see the help message. If you get "command not found", make sure the installation directory is in your PATH.

Uninstalling GitR

Linux/macOS:

sudo rm /usr/local/bin/gitr
# Or if installed for user only:
rm ~/bin/gitr

Windows:

# Remove from Program Files
Remove-Item -Recurse -Force "$env:ProgramFiles\GitR"
# Remove from PATH (requires manual editing of system environment variables)

Quick Start

1. First-Time Setup

Run GitR for the first time to set up your configuration:

gitr

This will guide you through:

  • Setting up your API key
  • Configuring your preferred model
  • Setting commit message preferences

Supported AI Providers

GitR supports multiple AI providers:

OpenAI

  • Base URL: https://api.openai.com/v1
  • Models: gpt-3.5-turbo, gpt-4, etc.
  • Get API Key: OpenAI Platform

Shivaay (FuturixAI)

Other OpenAI-Compatible APIs

GitR works with any OpenAI-compatible API endpoint. Simply configure the base URL and model name in your settings.

2. Basic Usage

# Generate and display commit message
gitr

# Generate message and commit with confirmation
gitr -c

# Generate message and commit without confirmation
gitr -c -b

# Edit configuration
gitr config

Usage

Command Line Options

Option Description
gitr Generate and display commit message
gitr -c, --commit Generate message and commit with confirmation
gitr -c -b, --bypass Generate message and commit without confirmation
gitr --help, -h Show help information
gitr config Open configuration editor

Examples

# Just generate a commit message
gitr

# Commit with interactive confirmation
gitr -c

# Quick commit without confirmation
gitr -c -b

# Edit your settings
gitr config

# Show help
gitr --help

Configuration

GitR looks for configuration files in the following order:

  1. .gitr_config in current directory
  2. ~/.gitr_config in home directory
  3. ~/.config/gitr/config in standard config location

Configuration Options

AI Provider Settings

  • API Key: Your API key from your chosen provider
  • Base URL: API endpoint
    • OpenAI: https://api.openai.com/v1
    • Shivaay: https://api.futurixai.com/api/shivaay/v1
  • Model: Model to use
    • OpenAI: gpt-3.5-turbo, gpt-4, etc.
    • Shivaay: shivaay
  • Max Tokens: Maximum response length
  • Temperature: Response creativity (0.0-2.0)
  • Timeout: Request timeout in seconds

Commit Template Settings

  • Style: Commit message style (conventional, simple, etc.)
  • Max Length: Maximum commit message length
  • Include Scope: Whether to include scope in commit messages
  • Commit Without Confirmation: Default behavior for commits

Example Configurations

OpenAI Configuration

<?xml version="1.0" encoding="UTF-8"?>
<config>
  <openai>
    <by_azure>false</by_azure>
    <base_url>https://api.openai.com/v1</base_url>
    <api_version>2023-05-15</api_version>
    <api_key>your-openai-api-key-here</api_key>
    <timeout>30</timeout>
    <model>gpt-3.5-turbo</model>
    <max_tokens>150</max_tokens>
    <temperature>0.7</temperature>
    <top_p>1.0</top_p>
    <stop></stop>
    <presence_penalty>0.0</presence_penalty>
    <frequency_penalty>0.0</frequency_penalty>
    <response_format></response_format>
    <seed></seed>
    <logit_bias></logit_bias>
    <user></user>
  </openai>
  <commit_template>
    <style>conventional</style>
    <max_length>72</max_length>
    <include_scope>true</include_scope>
    <commit_without_confirmation>false</commit_without_confirmation>
  </commit_template>
</config>

Shivaay Configuration

<?xml version="1.0" encoding="UTF-8"?>
<config>
  <openai>
    <by_azure>false</by_azure>
    <base_url>https://api.futurixai.com/api/shivaay/v1</base_url>
    <api_version>2023-05-15</api_version>
    <api_key>your-shivaay-api-key-here</api_key>
    <timeout>30</timeout>
    <model>shivaay</model>
    <max_tokens>150</max_tokens>
    <temperature>0.7</temperature>
    <top_p>1.0</top_p>
    <stop></stop>
    <presence_penalty>0.0</presence_penalty>
    <frequency_penalty>0.0</frequency_penalty>
    <response_format></response_format>
    <seed></seed>
    <logit_bias></logit_bias>
    <user></user>
  </openai>
  <commit_template>
    <style>conventional</style>
    <max_length>72</max_length>
    <include_scope>true</include_scope>
    <commit_without_confirmation>false</commit_without_confirmation>
  </commit_template>
</config>

Workflow Examples

Interactive Commit Workflow

$ git add .
$ gitr -c

Generated Commit Message:
==================================================
feat: Add user authentication system
==================================================

Options:
 [a] Accept and commit (default)
 [e] Edit message
 [r] Reject (don't commit)

Choose an option [a/e/r] (or press Enter to accept):

Quick Commit Workflow

$ git add .
$ gitr -c -b

 Bypassing confirmation (using generated message)...
 Committing changes...
 Commit successful!
 Committed with message: feat: Add user authentication system

Message Generation Only

$ git add .
$ gitr

Generated commit message:
==================================================
feat: Add user authentication system
==================================================

Requirements

  • Must be run in a Git repository
  • Must have staged changes (for commit operations)
  • Requires API key and model configuration (OpenAI, Shivaay, or compatible API)
  • Go 1.21+ for building from source

Troubleshooting

Common Issues

"Not in a git repository"

  • Ensure you're in a Git repository directory
  • Run git init if needed

"No staged changes found"

  • Stage your changes first: git add .
  • Or use gitr without -c to just generate a message

"Configuration error"

  • Run gitr config to set up your configuration
  • Ensure your API key is valid
  • Check your model name is correct

"Error generating commit message"

  • Verify your API key is working
  • Check your internet connection
  • Ensure you have sufficient API credits

Getting Help

gitr --help

Development

Project Structure

gitr/
├── main.go                 # Main entry point
├── cmd/                    # CLI commands
│   └── root.go
├── internal/
│   ├── config/            # Configuration management
│   │   ├── config.go
│   │   └── tui.go
│   ├── git/               # Git operations
│   │   └── git.go
│   ├── llm/               # AI integration
│   │   └── llm.go
│   └── output/            # Response parsing and TUI
│       ├── output.go
│       └── commit_tui.go
└── README.md

Building

go build .

Dependencies

  • github.com/cloudwego/eino - LLM framework
  • github.com/cloudwego/eino-ext - OpenAI integration
  • github.com/spf13/cobra - CLI framework
  • github.com/charmbracelet/bubbletea - TUI framework
  • github.com/charmbracelet/lipgloss - Styling

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

Acknowledgments

  • Built with CloudWeGo Eino for LLM integration
  • Uses Cobra for CLI functionality
  • Inspired by conventional commit standards

About

GitR is a tool that uses an LLM to generate conventional commit messages based on your staged changes.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages