Elevate your Git history with LogPolish - the intelligent CLI tool that transforms your commit messages using the power of AI!
- 🤖 Leverages AI (Claude or OpenAI) to generate concise and informative commit messages
- 🔄 Interactive mode for reviewing and updating suggested messages
- 🔍 Diff viewer for informed decision-making
- 🏷️ Custom prefix support for standardized commit messages
- 🔐 Secure API key management with .env file
- 🔀 Supports multiple Git branches
- 🎨 Rich, colorful console output for better readability
- 🖥️ Cross-platform compatibility (Windows, macOS, Linux)
- Python 3.7+
- Git
- PowerShell (for Windows users)
- Bash or Zsh (for macOS and Linux users)
LogPolish requires PowerShell for some operations on Windows. Most modern Windows systems come with PowerShell pre-installed. If you don't have PowerShell:
- Open the Microsoft Store
- Search for "PowerShell"
- Install the application published by Microsoft Corporation
Make sure you can run PowerShell scripts by setting the execution policy. Open PowerShell as Administrator and run:
Set-ExecutionPolicy RemoteSigned
Choose 'Y' when prompted.
-
Clone the repository:
git clone https://github.com/nathanclark/logpolish.git cd logpolish
-
Install the required dependencies:
pip install -r requirements.txt
-
Set up your API key: Run the script and follow the prompts to set up your Claude AI or OpenAI API key:
python logpolish.py
Basic usage:
python logpolish.py --repo-path /path/to/your/repo --branch main --count 5 --prefix "[FEATURE]"
Options:
--repo-path
: Path to the Git repository (default: current directory)--branch
: Branch to analyze (default: HEAD)--count
: Number of recent commits to analyze (default: 5)--prefix
: Prefix to add to all commit messages (optional)
LogPolish modifies existing commit messages, which rewrites Git history. This is generally safe for local branches that haven't been pushed to a shared repository. However, if you've already pushed your commits, changing them can cause issues for other contributors.
Use LogPolish with caution on shared branches. If you must use it on a branch that others are working on, make sure to communicate with your team and have them rebase their work.
Remember: Never rewrite the history of public branches (like main
or master
) unless you're absolutely sure about the consequences and have coordinated with all contributors.
- LogPolish analyzes recent commits in your specified Git branch.
- It uses AI to generate improved commit messages based on the diff.
- You can review, accept, update, or skip each suggested message.
- Accepted messages are automatically applied to your Git history.
To see LogPolish in action, you can create a mock repository and run the tool on it. Here's how:
-
Create a new directory and initialize a Git repository:
mkdir demo-repo && cd demo-repo git init
-
Create a README and make the initial commit:
echo "# Sample Project" > README.md git add README.md git commit -m "Initial commit"
-
Add a main Python script:
echo "def hello_world():\n print('Hello, World!')" > main.py git add main.py git commit -m "Add main script"
-
Create a .gitignore file:
echo "# Ignore virtual environment\nvenv/\n\n# Ignore pycache\n__pycache__/" > .gitignore git add .gitignore git commit -m "Add gitignore file"
-
Add a feature to the main script:
echo "def greet(name):\n print(f'Hello, {name}!')\n\ndef hello_world():\n print('Hello, World!')" > main.py git add main.py git commit -m "Add greet function"
-
Create a requirements file:
echo "requests==2.26.0" > requirements.txt git add requirements.txt git commit -m "Add requirements.txt"
-
Add a license file:
echo "MIT License\n\nCopyright (c) 2023 Your Name" > LICENSE git add LICENSE git commit -m "Add MIT license"
-
Create a setup script:
echo "from setuptools import setup\n\nsetup(\n name='sample-project',\n version='0.1',\n py_modules=['main'],\n)" > setup.py git add setup.py git commit -m "Add setup.py for packaging"
-
Add a test file:
mkdir tests echo "import unittest\nfrom main import greet\n\nclass TestGreet(unittest.TestCase):\n def test_greet(self):\n self.assertEqual(greet('Alice'), 'Hello, Alice!')" > tests/test_main.py git add tests/test_main.py git commit -m "Add unit test for greet function"
-
Update README with usage instructions:
echo "# Sample Project\n\nA simple Python project demonstrating 'Hello, World!' and a greeting function.\n\n## Usage\n\n\`\`\`python\nfrom main import hello_world, greet\n\nhello_world()\ngreet('Alice')\n\`\`\`" > README.md git add README.md git commit -m "Update README with usage instructions"
Now, run LogPolish on this repository to see it in action:
python path/to/logpolish.py --repo-path . --count 10
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
- Click for the CLI interface
- Rich for beautiful terminal formatting
- GitPython for Git integration
- Anthropic and OpenAI for AI capabilities
You can uninstall LogPolish either manually or by using the provided uninstall script.
-
Remove the LogPolish directory:
rm -rf /path/to/logpolish
-
Remove the .env file if you want to delete your API keys:
rm /path/to/.env
-
Optionally, uninstall the dependencies if you don't need them for other projects:
pip uninstall -r requirements.txt -y
We provide an uninstall.py
script for easy removal of LogPolish:
-
Navigate to the LogPolish directory:
cd /path/to/logpolish
-
Run the uninstall script:
python uninstall.py
This script will remove the LogPolish files, the .env file, and optionally uninstall the dependencies.
Made with ❤️ by Nathan
Give your Git logs a polish with LogPolish! ✨